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

Function parse_method

parser/parse_methods.c:57–337  ·  view source on GitHub ↗

* Parse a method pointed by start, end is the last character to check (if NULL * assume that start is a zero terminated string) * => assign enum bit to method. * Returns pointer to next char if parse succeeded * and NULL otherwise. */

Source from the content-addressed store, hash-verified

55 * and NULL otherwise.
56 */
57char* parse_method(char* start, char* end, unsigned int* method)
58{
59 int len=0;
60 int max=0;
61
62 if (!start || !method) {
63 LM_ERR("invalid parameter value\n");
64 return NULL;
65 }
66
67 if(end)
68 max = end - start;
69 *method = METHOD_UNDEF;
70
71 switch (start[0]) {
72 case 'A':
73 case 'a':
74 if(end && max<3)
75 goto unknown;
76
77 if ((start[1]=='c' || start[1]=='C')
78 && (start[2]=='k' || start[2]=='K'))
79 {
80 *method = METHOD_ACK;
81 len = 3;
82 goto done;
83 }
84 goto unknown;
85
86 case 'B':
87 case 'b':
88 if(end && max<3)
89 goto unknown;
90
91 if ((start[1]=='y' || start[1]=='Y')
92 && (start[2]=='e' || start[2]=='E'))
93 {
94 *method = METHOD_BYE;
95 len = 3;
96 goto done;
97 }
98 goto unknown;
99
100 case 'C':
101 case 'c':
102 if(end && max<6)
103 goto unknown;
104 if ((start[1]=='a' || start[1]=='A')
105 && (start[2]=='n' || start[2]=='N')
106 && (start[3]=='c' || start[3]=='C')
107 && (start[4]=='e' || start[4]=='E')
108 && (start[5]=='l' || start[5]=='L'))
109 {
110 *method = METHOD_CANCEL;
111 len = 6;
112 goto done;
113 }
114 goto unknown;

Callers 12

b2b_ua_replyFunction · 0.85
b2b_ua_mi_replyFunction · 0.85
_client_newFunction · 0.85
_b2b_send_replyFunction · 0.85
_b2b_send_requestFunction · 0.85
b2b_tm_cbackFunction · 0.85
t_uacFunction · 0.85
b2b_script_bridge_retryFunction · 0.85
_b2b_handle_replyFunction · 0.85
parse_methodsFunction · 0.85
parse_cseqFunction · 0.85
parse_first_lineFunction · 0.85

Calls 1

method_charFunction · 0.85

Tested by

no test coverage detected