osip和mysql_osip2/eXosip2调试笔记

软件版本: libosip2-3.3.0.tar.gz libeXosip2-3.3.0.tar.gz ./configure --prefix=/opt/sip/target --disable-static make make install 测试代码: 代码来源:http://blog.csdn.net/bat603/archive/2006/11/15/1386277.aspx 1、UAS //*******************U

软件版本:

libosip2-3.3.0.tar.gz

libeXosip2-3.3.0.tar.gz

./configure --prefix=/opt/sip/target --disable-static

make

make install

测试代码:

代码来源:http://blog.csdn.net/bat603/archive/2006/11/15/1386277.aspx

1、UAS

//*******************UAS**************************************************//

#include #include #include #include #include #include #include int

main (int argc, char *argv[])

{

eXosip_event_t *je = NULL;

osip_message_t *ack = NULL;

osip_message_t *invite = NULL;

osip_message_t *answer = NULL;

sdp_message_t *remote_sdp = NULL;

int call_id, dialog_id;

int i,j;

int id;

char *sour_call = "sip:133@192.168.0.133";

char *dest_call = "sip:140@192.168.0.140:5060";

char command;

char tmp[4096];

char localip[128];

int pos = 0;

//初始化sip

i = eXosip_init ();

if (i != 0)

{

printf ("Can't initialize eXosip!/n");

return -1;

}

else

{

printf ("eXosip_init successfully!/n");

}

i = eXosip_listen_addr (IPPROTO_UDP, NULL, 5060, AF_INET, 0);

if (i != 0)

{

eXosip_quit ();

fprintf (stderr, "eXosip_listen_addr error!/nCouldn't initialize transport layer!/n");

}

for(;;)

{

//侦听是否有消息到来

je = eXosip_event_wait (0,50);

//协议栈带有此语句,具体作用未知

eXosip_lock ();

eXosip_default_action (je);

eXosip_automatic_refresh ();

eXosip_unlock ();

if (je == NULL)//没有接收到消息

continue;

// printf ("the cid is %s, did is %s/n", je->did, je->cid);

switch (je->type)

{

case EXOSIP_MESSAGE_NEW://新的消息到来

printf (" EXOSIP_MESSAGE_NEW!/n");

if (MSG_IS_MESSAGE (je->request))//如果接受到的消息类型是MESSAGE

{

{

osip_body_t *body;

osip_message_get_body (je->request, 0, &body);

printf ("I get the msg is: %s/n", body->body);

//printf ("the cid is %s, did is %s/n", je->did, je->cid);

}

//按照规则,需要回复200 OK信息

eXosip_message_build_answer (je->tid, 200,&answer);

eXosip_message_send_answer (je->tid, 200,answer);

}

break;

case EXOSIP_CALL_INVITE:

//得到接收到消息的具体信息

printf ("Received a INVITE msg from %s:%s, UserName is %s, password is %s/n",je->request->req_uri->

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值