Browse code

Adding faked_msg.[ch] from kamailio core

These files are missing in the sip-router core

Jan Janak authored on 08/03/2009 22:42:13
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,64 @@
1
+/**
2
+ * $Id$
3
+ *
4
+ * Copyright (C) 2009 Daniel-Constantin Mierla (asipto.com)
5
+ *
6
+ * This file is part of kamailio, a free SIP server.
7
+ *
8
+ * openser is free software; you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation; either version 2 of the License, or
11
+ * (at your option) any later version
12
+ *
13
+ * openser is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
20
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
+ */
22
+
23
+#include "../../dprint.h"
24
+#include "../../globals.h"
25
+#include "../../dset.h"
26
+
27
+#include "faked_msg.h"
28
+
29
+#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"
30
+#define FAKED_SIP_MSG_LEN (sizeof(FAKED_SIP_MSG)-1)
31
+static char _faked_sip_buf[FAKED_SIP_MSG_LEN+1];
32
+static struct sip_msg _faked_msg;
33
+static unsigned int _faked_msg_no = 0;
34
+
35
+int faked_msg_init(void)
36
+{
37
+	if(_faked_msg_no>0)
38
+		return 0;
39
+	/* init faked sip msg */
40
+	memcpy(_faked_sip_buf, FAKED_SIP_MSG, FAKED_SIP_MSG_LEN);
41
+	_faked_sip_buf[FAKED_SIP_MSG_LEN] = '\0';
42
+	
43
+	memset(&_faked_msg, 0, sizeof(struct sip_msg));
44
+
45
+	_faked_msg.buf=_faked_sip_buf;
46
+	_faked_msg.len=FAKED_SIP_MSG_LEN;
47
+
48
+	_faked_msg.set_global_address=default_global_address;
49
+	_faked_msg.set_global_port=default_global_port;
50
+
51
+	if (parse_msg(_faked_msg.buf, _faked_msg.len, &_faked_msg)!=0)
52
+	{
53
+		LM_ERR("parse_msg failed\n");
54
+		return -1;
55
+	}
56
+	return 0;
57
+}
58
+
59
+struct sip_msg* faked_msg_next(void)
60
+{
61
+	_faked_msg.id=_faked_msg_no++;
62
+	clear_branches();
63
+	return &_faked_msg;
64
+}
0 65
new file mode 100644
... ...
@@ -0,0 +1,31 @@
1
+/**
2
+ * $Id$
3
+ *
4
+ * Copyright (C) 2009 Daniel-Constantin Mierla (asipto.com)
5
+ *
6
+ * This file is part of kamailio, a free SIP server.
7
+ *
8
+ * kamailio is free software; you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation; either version 2 of the License, or
11
+ * (at your option) any later version
12
+ *
13
+ * kamailio is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
20
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
+ */
22
+		       
23
+#ifndef _FAKED_SIP_MSG_H_
24
+#define _FAKED_SIP_MSG_H_
25
+
26
+#include "../../parser/msg_parser.h"
27
+
28
+int faked_msg_init(void);
29
+struct sip_msg* faked_msg_next(void);
30
+
31
+#endif