解析SIP消息体 [英] Parsing SIP message body
问题描述
我实现SIP协议,在分析SIP消息,我卡住了。我使用OSIP库。我的code是这样的:
I'm implementing SIP protocol and I'm stuck while parsing SIP message. I'm using the oSIP library. My code is like that:
#include <stdio.h>
#include <stdlib.h>
#include <osip2/osip.h>
#include <osipparser2/osip_parser.h>
#include <string.h>
void main()
{
int i,error;
osip_message_t *message;
char text[]="INVITE sip:jarsku@feanor.pc.lut.fi SIP/2.0\nCall-ID: 123456789@aradan\nVia: SIP/2.0/UDP 157.24.25.137:5060\nFrom: Arto <sip:athamala@feanor.pc.lut.fi>\nTo: Jari <sip:jarsku@feanor.pc.lut.fi>\nCSeq: 1 INVITE\nContent-Type: application/sdp\n\nv=0\na=3333aaa333";
char *p=(char *)&text;
i = strlen(text);
error = osip_init(&message);
error = osip_message_init(&message);
error = osip_message_parse(message, p, i);
}
当我运行这个code,消息结构中满是文本数据。各领域 CALL_ID,content_lenght,CONTENT_TYPE,Cseq的,从,req_uri,sip_method,sip_version,
来和过孔正确填写,但在现场的消息是价值为0x0, message_length中
0和message_property为2。
错误codeS为0所有三个命令。
为什么邮件正文中没有解析?我很困惑这件事情:
在RFC中指出,每行应该以CLRF序列结束,但我只是用 \\ n
和它看起来像工作。
接下来,我不喜欢这样的语句:
When I run this code, the message structure is filled with data from text. Respective the fields call_id, content_lenght, content_type, cseq, from, req_uri, sip_method, sip_version,
to and vias are filled correctly, but in the field message is value 0x0, message_length
is 0 and message_property is 2.
Error codes are 0 for all three commands.
Why is the message body not parsed ? I'm confused of this things:
In RFC is stated, that every line should be ended with CLRF sequence, but I'm simply using \n
and it seems like working.
Next I dont like this statement:
error = osip_init(&message);
error = osip_message_init(&message);
对于我来说,这是不可思议。在约瑟夫的文档说明的是序列:
For me, is this weird. In the documentation of oSIP is stated that sequence of:
osip_message_t *sip;
osip_message_init(&sip);
osip_message_parse(sip, buffer, length_of_buffer);
osip_message_free(sip);
应该是足够的(在我使用init和message_init我的code),但是这是我扔分割故障。
should be enough (in my code I'm using init and message_init), but this is throwing me a Segmentation fault.
为什么是可能的,该字段 CONTENT_LENGTH
的自动填充,但该消息未解析?
And why is possible, that the field content_length
is autofilled but the message is not parsed ?
最后一个问题:为什么这个话题如此可怕覆盖在互联网?没有说明书,OSIP文档坏
Last question : why is this topic so terribly covered on Internet ? No manuals, oSIP documentation is bad
感谢您
推荐答案
我想你可能会读取文件错误。该功能osip_init()想要一个osip_t **约瑟夫没有消息。回复:的http://www.gnu.org/software/osip/doc/html/group_howto0_initialize.html
I think you might be reading the documentation wrong. The function osip_init() wants a osip_t **osip not a message. Re: http://www.gnu.org/software/osip/doc/html/group_howto0_initialize.html
这篇关于解析SIP消息体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!