diff --git a/core/plug-in/sipctrl/SipCtrlInterface.cpp b/core/plug-in/sipctrl/SipCtrlInterface.cpp index e216ee9b..2f9542ed 100644 --- a/core/plug-in/sipctrl/SipCtrlInterface.cpp +++ b/core/plug-in/sipctrl/SipCtrlInterface.cpp @@ -438,7 +438,7 @@ void SipCtrlInterface::handle_sip_request(const char* tid, sip_msg* msg) if(msg->contact){ sip_nameaddr na; - char* c = msg->contact->value.s; + const char* c = msg->contact->value.s; if(parse_nameaddr(&na,&c,msg->contact->value.len) < 0){ DBG("Contact parsing failed\n"); } @@ -496,7 +496,7 @@ void SipCtrlInterface::handle_sip_reply(sip_msg* msg) if(msg->contact){ - char* c = msg->contact->value.s; + const char* c = msg->contact->value.s; sip_nameaddr na; int err = parse_nameaddr(&na,&c,msg->contact->value.len); diff --git a/core/plug-in/sipctrl/cstring.h b/core/plug-in/sipctrl/cstring.h index bb33a211..26dc2ea8 100644 --- a/core/plug-in/sipctrl/cstring.h +++ b/core/plug-in/sipctrl/cstring.h @@ -32,7 +32,7 @@ struct cstring { - char* s; + const char* s; int len; cstring() @@ -43,11 +43,15 @@ struct cstring : s(s), len(strlen(s)) {} - cstring(char* s, int l) - : s(s), len(l) + cstring(const char* s) + : s(s), len(strlen(s)) + {} + + cstring(const char* s, int l) + : s(s), len(l) {} - void set(char* _s, int _len){ + void set(const char* _s, int _len){ s = _s; len = _len; } @@ -56,6 +60,7 @@ struct cstring s = 0; len = 0; } + }; #define c2stlstr(str) \ diff --git a/core/plug-in/sipctrl/hash_table.cpp b/core/plug-in/sipctrl/hash_table.cpp index b4753d3d..dc6f03ee 100644 --- a/core/plug-in/sipctrl/hash_table.cpp +++ b/core/plug-in/sipctrl/hash_table.cpp @@ -101,7 +101,7 @@ sip_trans* trans_bucket::match_request(sip_msg* msg) DBG("do_3261_match = %i\n",do_3261_match); if(do_3261_match){ - char* branch = msg->via_p1->branch.s + MAGIC_BRANCH_LEN; + const char* branch = msg->via_p1->branch.s + MAGIC_BRANCH_LEN; int len = msg->via_p1->branch.len - MAGIC_BRANCH_LEN; trans_list::iterator it = elmts.begin(); @@ -273,7 +273,7 @@ sip_trans* trans_bucket::match_reply(sip_msg* msg) sip_trans* t = NULL; - char* branch = msg->via_p1->branch.s + MAGIC_BRANCH_LEN; + const char* branch = msg->via_p1->branch.s + MAGIC_BRANCH_LEN; int len = msg->via_p1->branch.len - MAGIC_BRANCH_LEN; assert(get_cseq(msg)); diff --git a/core/plug-in/sipctrl/parse_common.cpp b/core/plug-in/sipctrl/parse_common.cpp index e2e8ea9d..d0274ccd 100644 --- a/core/plug-in/sipctrl/parse_common.cpp +++ b/core/plug-in/sipctrl/parse_common.cpp @@ -38,16 +38,16 @@ using std::auto_ptr; // SIP version constants // -char* SIP = "SIP"; +const char* SIP = "SIP"; #define SIP_len 3 -char* SUP_SIPVER = "2.0"; +const char* SUP_SIPVER = "2.0"; #define SUP_SIPVER_len 3 -int parse_sip_version(char* beg, int len) +int parse_sip_version(const char* beg, int len) { - char* c = beg; + const char* c = beg; //char* end = c+len; if(len!=7){ @@ -76,7 +76,7 @@ int parse_sip_version(char* beg, int len) } -int parse_gen_params(list* params, char** c, int len, char stop_char) +int parse_gen_params(list* params, const char** c, int len, char stop_char) { enum { VP_PARAM_SEP=0, @@ -88,8 +88,8 @@ int parse_gen_params(list* params, char** c, int len, char stop_char) VP_PVALUE_QUOTED }; - char* beg = *c; - char* end = beg+len; + const char* beg = *c; + const char* end = beg+len; int saved_st=0,st=VP_PARAM_SEP; auto_ptr avp(new sip_avp()); diff --git a/core/plug-in/sipctrl/parse_common.h b/core/plug-in/sipctrl/parse_common.h index 23a6ba5f..89ef955a 100644 --- a/core/plug-in/sipctrl/parse_common.h +++ b/core/plug-in/sipctrl/parse_common.h @@ -144,9 +144,9 @@ struct sip_avp // Functions // -inline int lower_cmp(char* l, char* r, int len) +inline int lower_cmp(const char* l, const char* r, int len) { - char* end = l+len; + const char* end = l+len; while(l!=end){ if( LOWER_B(*l) != *r ){ @@ -158,8 +158,8 @@ inline int lower_cmp(char* l, char* r, int len) return 0; } -int parse_sip_version(char* beg, int len); +int parse_sip_version(const char* beg, int len); -int parse_gen_params(list* params, char** c, int len, char stop_char); +int parse_gen_params(list* params, const char** c, int len, char stop_char); #endif diff --git a/core/plug-in/sipctrl/parse_cseq.cpp b/core/plug-in/sipctrl/parse_cseq.cpp index f4c21cb7..d8efa58b 100644 --- a/core/plug-in/sipctrl/parse_cseq.cpp +++ b/core/plug-in/sipctrl/parse_cseq.cpp @@ -30,7 +30,7 @@ #include "log.h" -int parse_cseq(sip_cseq* cseq, char* beg, int len) +int parse_cseq(sip_cseq* cseq, const char* beg, int len) { enum { C_NUM=0, @@ -39,8 +39,8 @@ int parse_cseq(sip_cseq* cseq, char* beg, int len) }; - char* c = beg; - char* end = c+len; + const char* c = beg; + const char* end = c+len; int saved_st=0, st=C_NUM; diff --git a/core/plug-in/sipctrl/parse_cseq.h b/core/plug-in/sipctrl/parse_cseq.h index 085fc937..6e342475 100644 --- a/core/plug-in/sipctrl/parse_cseq.h +++ b/core/plug-in/sipctrl/parse_cseq.h @@ -45,7 +45,7 @@ struct sip_cseq: public sip_parsed_hdr {} }; -int parse_cseq(sip_cseq* cseq, char* beg, int len); +int parse_cseq(sip_cseq* cseq, const char* beg, int len); inline sip_cseq* get_cseq(sip_msg* msg) { diff --git a/core/plug-in/sipctrl/parse_from_to.cpp b/core/plug-in/sipctrl/parse_from_to.cpp index 2b84bb65..d3146a70 100644 --- a/core/plug-in/sipctrl/parse_from_to.cpp +++ b/core/plug-in/sipctrl/parse_from_to.cpp @@ -38,7 +38,7 @@ sip_from_to::~sip_from_to() } } -int parse_nameaddr(sip_nameaddr* na, char** c, int len) +int parse_nameaddr(sip_nameaddr* na, const char** c, int len) { enum { @@ -52,10 +52,10 @@ int parse_nameaddr(sip_nameaddr* na, char** c, int len) }; - char* beg = *c; - char* end = *c + len; + const char* beg = *c; + const char* end = *c + len; - char* uri_end=0; + const char* uri_end=0; int saved_st=0, st=NA_SWS; //int ret=0; @@ -232,7 +232,7 @@ int parse_nameaddr(sip_nameaddr* na, char** c, int len) } -int parse_from_to(sip_from_to* ft, char* beg, int len) +int parse_from_to(sip_from_to* ft, const char* beg, int len) { enum { FTP_BEG, @@ -244,8 +244,8 @@ int parse_from_to(sip_from_to* ft, char* beg, int len) FTP_OTHER }; - char* c = beg; - char* end = c+len; + const char* c = beg; + const char* end = c+len; int ret = parse_nameaddr(&ft->nameaddr,&c,len); if(ret) return ret; @@ -257,8 +257,8 @@ int parse_from_to(sip_from_to* ft, char* beg, int len) list::iterator it = ft->params.begin(); for(;it!=ft->params.end();++it){ - char* c = (*it)->name.s; - char* end = c + (*it)->name.len; + const char* c = (*it)->name.s; + const char* end = c + (*it)->name.len; int st = FTP_BEG; for(;c!=end;c++){ diff --git a/core/plug-in/sipctrl/parse_from_to.h b/core/plug-in/sipctrl/parse_from_to.h index af799db1..a6a27dc4 100644 --- a/core/plug-in/sipctrl/parse_from_to.h +++ b/core/plug-in/sipctrl/parse_from_to.h @@ -56,8 +56,8 @@ struct sip_from_to: public sip_parsed_hdr ~sip_from_to(); }; -int parse_nameaddr(sip_nameaddr* na, char** c, int len); -int parse_from_to(sip_from_to* ft, char* beg, int len); +int parse_nameaddr(sip_nameaddr* na, const char** c, int len); +int parse_from_to(sip_from_to* ft, const char* beg, int len); inline sip_from_to* get_from(sip_msg* msg) { diff --git a/core/plug-in/sipctrl/parse_header.cpp b/core/plug-in/sipctrl/parse_header.cpp index bda1abf4..931bc37a 100644 --- a/core/plug-in/sipctrl/parse_header.cpp +++ b/core/plug-in/sipctrl/parse_header.cpp @@ -58,16 +58,16 @@ using std::auto_ptr; // Low case headers // -char* TO_lc = "to"; -char* VIA_lc = "via"; -char* FROM_lc = "from"; -char* CSEQ_lc = "cseq"; -char* ROUTE_lc = "route"; -char* CALL_ID_lc = "call-id"; -char* CONTACT_lc = "contact"; -char* CONTENT_TYPE_lc = "content-type"; -char* RECORD_ROUTE_lc = "record-route"; -char* CONTENT_LENGTH_lc = "content-length"; +const char* TO_lc = "to"; +const char* VIA_lc = "via"; +const char* FROM_lc = "from"; +const char* CSEQ_lc = "cseq"; +const char* ROUTE_lc = "route"; +const char* CALL_ID_lc = "call-id"; +const char* CONTACT_lc = "contact"; +const char* CONTENT_TYPE_lc = "content-type"; +const char* RECORD_ROUTE_lc = "record-route"; +const char* CONTENT_LENGTH_lc = "content-length"; sip_header::sip_header() diff --git a/core/plug-in/sipctrl/parse_uri.cpp b/core/plug-in/sipctrl/parse_uri.cpp index 0e1a9dfe..a75fe8ae 100644 --- a/core/plug-in/sipctrl/parse_uri.cpp +++ b/core/plug-in/sipctrl/parse_uri.cpp @@ -48,7 +48,7 @@ sip_uri::~sip_uri() } -static int parse_sip_uri(sip_uri* uri, char* beg, int len) +static int parse_sip_uri(sip_uri* uri, const char* beg, int len) { enum { URI_USER=0, @@ -62,7 +62,7 @@ static int parse_sip_uri(sip_uri* uri, char* beg, int len) }; int st = URI_HOST; - char* c = beg; + const char* c = beg; //int escaped = 0; cstring tmp1, tmp2; @@ -316,7 +316,7 @@ static int parse_sip_uri(sip_uri* uri, char* beg, int len) return 0; } -int parse_uri(sip_uri* uri, char* beg, int len) +int parse_uri(sip_uri* uri, const char* beg, int len) { enum { URI_BEG=0, @@ -327,7 +327,7 @@ int parse_uri(sip_uri* uri, char* beg, int len) }; int st = URI_BEG; - char* c = beg; + const char* c = beg; for(;c!=beg+len;c++){ switch(st){ diff --git a/core/plug-in/sipctrl/parse_uri.h b/core/plug-in/sipctrl/parse_uri.h index 34c9de64..459dfbc5 100644 --- a/core/plug-in/sipctrl/parse_uri.h +++ b/core/plug-in/sipctrl/parse_uri.h @@ -57,6 +57,6 @@ struct sip_uri ~sip_uri(); }; -int parse_uri(sip_uri* uri, char* beg, int len); +int parse_uri(sip_uri* uri, const char* beg, int len); #endif diff --git a/core/plug-in/sipctrl/parse_via.cpp b/core/plug-in/sipctrl/parse_via.cpp index e26fcee1..27b3c45f 100644 --- a/core/plug-in/sipctrl/parse_via.cpp +++ b/core/plug-in/sipctrl/parse_via.cpp @@ -51,7 +51,7 @@ sip_via::~sip_via() } } -static int parse_transport(sip_transport* t, char** c, int len) +static int parse_transport(sip_transport* t, const char** c, int len) { enum { @@ -85,7 +85,7 @@ static int parse_transport(sip_transport* t, char** c, int len) t->val.s = *c; len -= SIPVER_len+1; - char* end = *c + len; + const char* end = *c + len; for(;**c && (*c!=end);(*c)++){ @@ -189,7 +189,7 @@ static int parse_transport(sip_transport* t, char** c, int len) return 0; } -static int parse_by(cstring* host, cstring* port, char** c, int len) +static int parse_by(cstring* host, cstring* port, const char** c, int len) { enum { BY_HOST=0, @@ -201,8 +201,8 @@ static int parse_by(cstring* host, cstring* port, char** c, int len) int saved_st=0, st=BY_HOST; - char* beg = *c; - char* end = beg+len; + const char* beg = *c; + const char* end = beg+len; for(;*c!=end;(*c)++){ @@ -347,7 +347,7 @@ static int parse_by(cstring* host, cstring* port, char** c, int len) return 0; } -inline int parse_via_params(sip_via_parm* parm, char** c, int len) +inline int parse_via_params(sip_via_parm* parm, const char** c, int len) { enum { VP_BEG=0, @@ -368,8 +368,8 @@ inline int parse_via_params(sip_via_parm* parm, char** c, int len) list::iterator it = parm->params.begin(); for(;it != parm->params.end();++it){ - char* c = (*it)->name.s; - char* end = c + (*it)->name.len; + const char* c = (*it)->name.s; + const char* end = c + (*it)->name.len; int st = VP_BEG; for(;c!=end;c++){ @@ -413,7 +413,7 @@ inline int parse_via_params(sip_via_parm* parm, char** c, int len) } -int parse_via(sip_via* via, char* beg, int len) +int parse_via(sip_via* via, const char* beg, int len) { enum { @@ -424,8 +424,8 @@ int parse_via(sip_via* via, char* beg, int len) }; - char* c = beg; - char* end = beg+len; + const char* c = beg; + const char* end = beg+len; int saved_st=0, st=V_TRANS; diff --git a/core/plug-in/sipctrl/parse_via.h b/core/plug-in/sipctrl/parse_via.h index 1e16054f..84ebedb1 100644 --- a/core/plug-in/sipctrl/parse_via.h +++ b/core/plug-in/sipctrl/parse_via.h @@ -67,7 +67,7 @@ struct sip_via: public sip_parsed_hdr ~sip_via(); }; -int parse_via(sip_via* via, char* beg, int len); +int parse_via(sip_via* via, const char* beg, int len); #define MAGIC_BRANCH_COOKIE "z9hG4bK" #define MAGIC_BRANCH_LEN 7 diff --git a/core/plug-in/sipctrl/sip_parser.cpp b/core/plug-in/sipctrl/sip_parser.cpp index 43988238..201c106f 100644 --- a/core/plug-in/sipctrl/sip_parser.cpp +++ b/core/plug-in/sipctrl/sip_parser.cpp @@ -112,29 +112,29 @@ sip_msg::~sip_msg() } -char* INVITEm = "INVITE"; +const char* INVITEm = "INVITE"; #define INVITE_len 6 -char* ACKm = "ACK"; +const char* ACKm = "ACK"; #define ACK_len 3 -char* OPTIONSm = "OPTIONS"; +const char* OPTIONSm = "OPTIONS"; #define OPTIONS_len 7 -char* BYEm = "BYE"; +const char* BYEm = "BYE"; #define BYE_len 3 -char* CANCELm = "CANCEL"; +const char* CANCELm = "CANCEL"; #define CANCEL_len 6 -char* REGISTERm = "REGISTER"; +const char* REGISTERm = "REGISTER"; #define REGISTER_len 8 -int parse_method(int* method, char* beg, int len) +int parse_method(int* method, const char* beg, int len) { - char* c = beg; - char* end = c+len; + const char* c = beg; + const char* end = c+len; *method = sip_request::OTHER_METHOD; diff --git a/core/plug-in/sipctrl/sip_parser.h b/core/plug-in/sipctrl/sip_parser.h index 31b20e01..b9a7b12e 100644 --- a/core/plug-in/sipctrl/sip_parser.h +++ b/core/plug-in/sipctrl/sip_parser.h @@ -127,7 +127,7 @@ struct sip_msg ~sip_msg(); }; -int parse_method(int* method, char* beg, int len); +int parse_method(int* method, const char* beg, int len); int parse_sip_msg(sip_msg* msg); #endif diff --git a/core/plug-in/sipctrl/trans_layer.cpp b/core/plug-in/sipctrl/trans_layer.cpp index fba12bca..b78d2493 100644 --- a/core/plug-in/sipctrl/trans_layer.cpp +++ b/core/plug-in/sipctrl/trans_layer.cpp @@ -260,7 +260,7 @@ int trans_layer::set_next_hop(list& route_hdrs, sip_header* fr = route_hdrs.front(); sip_nameaddr na; - char* c = fr->value.s; + const char* c = fr->value.s; if(parse_nameaddr(&na, &c, fr->value.len)<0) { DBG("Parsing name-addr failed\n"); @@ -309,7 +309,7 @@ int trans_layer::set_next_hop(list& route_hdrs, }; int st = RR_PARAMS; - char* end = fr->value.s + fr->value.len; + const char* end = fr->value.s + fr->value.len; for(;cu.request->ruri_str); char branch_buf[BRANCH_BUF_LEN]; + compute_branch(branch_buf,msg->callid->value,msg->cseq->value); cstring branch(branch_buf,BRANCH_BUF_LEN); - compute_branch(branch.s,msg->callid->value,msg->cseq->value); string via(transport->get_local_ip()); if(transport->get_local_port() != 5060) @@ -609,8 +609,8 @@ int trans_layer::cancel(trans_bucket* bucket, sip_trans* t) req->u.request->ruri_str); char branch_buf[BRANCH_BUF_LEN]; + compute_branch(branch_buf,req->callid->value,get_cseq(req)->num_str); cstring branch(branch_buf,BRANCH_BUF_LEN); - compute_branch(branch.s,req->callid->value,get_cseq(req)->num_str); string via(transport->get_local_ip()); if(transport->get_local_port() != 5060) @@ -1091,7 +1091,7 @@ void trans_layer::send_200_ack(sip_msg* reply) } sip_nameaddr na; - char* c = reply->contact->value.s; + const char* c = reply->contact->value.s; if(parse_nameaddr(&na,&c,reply->contact->value.len) < 0){ DBG("Sorry, reply's Contact parsing failed: could not send ACK\n"); return; @@ -1112,8 +1112,8 @@ void trans_layer::send_200_ack(sip_msg* reply) int request_len = request_line_len(cstring("ACK",3),r_uri); char branch_buf[BRANCH_BUF_LEN]; + compute_branch(branch_buf,reply->callid->value,reply->cseq->value); cstring branch(branch_buf,BRANCH_BUF_LEN); - compute_branch(branch.s,reply->callid->value,reply->cseq->value); sip_header* max_forward = new sip_header(0,cstring("Max-Forwards"),cstring("10")); @@ -1134,21 +1134,21 @@ void trans_layer::send_200_ack(sip_msg* reply) char* ack_buf = new char[request_len]; // generate it - c = ack_buf; + char* msg = ack_buf; - request_line_wr(&c,cstring("ACK",3),r_uri); - via_wr(&c,via,branch); + request_line_wr(&msg,cstring("ACK",3),r_uri); + via_wr(&msg,via,branch); - copy_hdrs_wr(&c,route_hdrs); + copy_hdrs_wr(&msg,route_hdrs); - copy_hdr_wr(&c,reply->from); - copy_hdr_wr(&c,reply->to); - copy_hdr_wr(&c,reply->callid); - copy_hdr_wr(&c,max_forward); - cseq_wr(&c,get_cseq(reply)->num_str,cstring("ACK",3)); + copy_hdr_wr(&msg,reply->from); + copy_hdr_wr(&msg,reply->to); + copy_hdr_wr(&msg,reply->callid); + copy_hdr_wr(&msg,max_forward); + cseq_wr(&msg,get_cseq(reply)->num_str,cstring("ACK",3)); - *c++ = CR; - *c++ = LF; + *msg++ = CR; + *msg++ = LF; DBG("About to send 200 ACK: \n<%.*s>\n",request_len,ack_buf);