MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / parse_via

Function parse_via

parser/parse_via.c:984–2305  ·  view source on GitHub ↗

* call it with a vb initialized to 0 * returns: pointer after the parsed parts and sets vb->error * WARNING: don't forget to cleanup on error with free_via_list(vb)! */

Source from the content-addressed store, hash-verified

982 * WARNING: don't forget to cleanup on error with free_via_list(vb)!
983 */
984char* parse_via(char* buffer, char* end, struct via_body *vbody)
985{
986 char* tmp;
987 char* param_start;
988 unsigned char state;
989 unsigned char saved_state;
990 int c_nest;
991 int err;
992 struct via_body* vb;
993 struct via_param* param;
994
995 vb=vbody; /* keep orignal vbody value, needed to set the error member
996 in case of multiple via bodies in the same header */
997parse_again:
998 vb->error=PARSE_ERROR;
999 /* parse start of via ( SIP/2.0/UDP )*/
1000 state=F_SIP;
1001 saved_state=0; /*it should generate error if it's used without set*/
1002 param_start=0;
1003 for(tmp=buffer;tmp<end;tmp++){
1004 switch(*tmp){
1005 case ' ':
1006 case'\t':
1007 switch(state){
1008 case L_VER: /* eat space */
1009 case L_PROTO:
1010 case F_SIP:
1011 case F_VER:
1012 case F_PROTO:
1013 break;
1014 case FIN_UDP:
1015 vb->transport.len=tmp-vb->transport.s;
1016 vb->proto=PROTO_UDP;
1017 state=F_HOST; /* start looking for host*/
1018 goto main_via;
1019 case FIN_TCP:
1020 /* finished proto parsing */
1021 vb->transport.len=tmp-vb->transport.s;
1022 vb->proto=PROTO_TCP;
1023 state=F_HOST; /* start looking for host*/
1024 goto main_via;
1025 case FIN_TLS:
1026 /* finished proto parsing */
1027 vb->transport.len=tmp-vb->transport.s;
1028 vb->proto=PROTO_TLS;
1029 state=F_HOST; /* start looking for host*/
1030 goto main_via;
1031 case FIN_SCTP:
1032 /* finished proto parsing */
1033 vb->transport.len=tmp-vb->transport.s;
1034 vb->proto=PROTO_SCTP;
1035 state=F_HOST; /* start looking for host*/
1036 goto main_via;
1037 case FIN_WS:
1038 case WS_WSS:
1039 /* finished proto parsing */
1040 vb->transport.len=tmp-vb->transport.s;
1041 vb->proto=PROTO_WS;

Callers 3

tr_eval_viaFunction · 0.85
sip_validate_hdrsFunction · 0.85
get_hdr_field_auxFunction · 0.85

Calls 2

parse_via_paramFunction · 0.85
str2sFunction · 0.85

Tested by

no test coverage detected