Commit 0b1f379f authored by Simon Morlat's avatar Simon Morlat

add more convenient functions for creating tags

parent 02a3abf2
......@@ -125,6 +125,8 @@ belle_sip_header_contact_t* belle_sip_header_contact_parse (const char* contact)
#define BELLE_SIP_HEADER_CONTACT(t) BELLE_SIP_CAST(t,belle_sip_header_contact_t)
#define BELLE_SIP_RANDOM_TAG ((const char*)-1)
/******************************
* From header object inherent from header_address
*
......
......@@ -242,7 +242,10 @@ int belle_sip_header_from_marshal(belle_sip_header_from_t* from, char* buff,unsi
belle_sip_header_from_t* belle_sip_header_from_create(const char *address, const char *tag){
char *tmp=belle_sip_strdup_printf("From: %s",address);
belle_sip_header_from_t *from=belle_sip_header_from_parse(tmp);
if (tag) belle_sip_header_from_set_tag(from,tag);
if (from){
if (tag==BELLE_SIP_RANDOM_TAG) belle_sip_header_from_set_random_tag(from);
else if (tag) belle_sip_header_from_set_tag(from,tag);
}
belle_sip_free(tmp);
return from;
}
......@@ -281,7 +284,10 @@ GET_SET_STRING_PARAM(belle_sip_header_to,tag);
belle_sip_header_to_t* belle_sip_header_to_create(const char *address, const char *tag){
char *tmp=belle_sip_strdup_printf("To: %s",address);
belle_sip_header_to_t *to=belle_sip_header_to_parse(tmp);
if (tag) belle_sip_header_to_set_tag(to,tag);
if (to){
if (tag==BELLE_SIP_RANDOM_TAG) belle_sip_header_to_set_random_tag(to);
else if (tag) belle_sip_header_to_set_tag(to,tag);
}
belle_sip_free(tmp);
return to;
}
......
......@@ -30,8 +30,8 @@ static void channel_state_changed(belle_sip_channel_listener_t *obj, belle_sip_c
if (state == BELLE_SIP_CHANNEL_ERROR) {
ev.transport=belle_sip_channel_get_transport_name(chan);
ev.source=(belle_sip_provider_t*)obj;
ev.port=chan->local_port;
ev.host=chan->local_ip;
ev.port=chan->peer_port;
ev.host=chan->peer_name;
BELLE_SIP_PROVIDER_INVOKE_LISTENERS(ev.source,process_io_error,&ev);
}
}
......
......@@ -109,7 +109,6 @@ static int uninit(void) {
}
static void register_test(const char *transport, int use_transaction) {
belle_sip_request_t *req;
char token[10];
char identity[256];
char uri[256];
......@@ -128,7 +127,7 @@ static void register_test(const char *transport, int use_transaction) {
"REGISTER",
belle_sip_provider_create_call_id(prov),
belle_sip_header_cseq_create(20,"REGISTER"),
belle_sip_header_from_create(identity,belle_sip_random_token(token,sizeof(token))),
belle_sip_header_from_create(identity,BELLE_SIP_RANDOM_TAG),
belle_sip_header_to_create(identity,NULL),
belle_sip_header_via_new(),
70);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment