00001 /** 00002 * $Id$ 00003 * 00004 * Copyright (C) 2009 Daniel-Constantin Mierla (asipto.com) 00005 * 00006 * This file is part of kamailio, a free SIP server. 00007 * 00008 * openser is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version 00012 * 00013 * openser is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 #include "dprint.h" 00024 #include "globals.h" 00025 #include "dset.h" 00026 00027 #include "faked_msg.h" 00028 00029 #define FAKED_SIP_MSG "OPTIONS sip:you@kamailio.org SIP/2.0\r\nVia: SIP/2.0/UDP 127.0.0.1\r\nFrom: <you@kamailio.org>;tag=123\r\nTo: <you@kamailio.org>\r\nCall-ID: 123\r\nCSeq: 1 OPTIONS\r\nContent-Length: 0\r\n\r\n" 00030 #define FAKED_SIP_MSG_LEN (sizeof(FAKED_SIP_MSG)-1) 00031 static char _faked_sip_buf[FAKED_SIP_MSG_LEN+1]; 00032 static struct sip_msg _faked_msg; 00033 static unsigned int _faked_msg_no = 0; 00034 00035 int faked_msg_init(void) 00036 { 00037 if(_faked_msg_no>0) 00038 return 0; 00039 /* init faked sip msg */ 00040 memcpy(_faked_sip_buf, FAKED_SIP_MSG, FAKED_SIP_MSG_LEN); 00041 _faked_sip_buf[FAKED_SIP_MSG_LEN] = '\0'; 00042 00043 memset(&_faked_msg, 0, sizeof(struct sip_msg)); 00044 00045 _faked_msg.buf=_faked_sip_buf; 00046 _faked_msg.len=FAKED_SIP_MSG_LEN; 00047 00048 _faked_msg.set_global_address=default_global_address; 00049 _faked_msg.set_global_port=default_global_port; 00050 00051 if (parse_msg(_faked_msg.buf, _faked_msg.len, &_faked_msg)!=0) 00052 { 00053 LM_ERR("parse_msg failed\n"); 00054 return -1; 00055 } 00056 return 0; 00057 } 00058 00059 struct sip_msg* faked_msg_next(void) 00060 { 00061 _faked_msg.id=_faked_msg_no++; 00062 clear_branches(); 00063 return &_faked_msg; 00064 }
1.5.6