2 * Copyright (C) 2001-2003 FhG Fokus
4 * This file is part of Kamailio, a free SIP server.
6 * Kamailio is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version
11 * Kamailio is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * @brief Parser :: Parse URI's
31 #include "../globals.h"
32 #include "parse_uri.h"
34 #include "../dprint.h"
35 #include "../ut.h" /* q_memchr */
37 #include "../core_stats.h"
39 static char _sr_uri_empty_buf[2] = {0};
40 static str _sr_uri_empty = { _sr_uri_empty_buf, 0 };
42 /* extra chars that should be allowed in URI host */
43 char *_sr_uri_host_extra_chars = "";
45 int uri_host_char_allowed(char c)
49 if(_sr_uri_host_extra_chars==NULL || _sr_uri_host_extra_chars[0]=='\0') {
52 while(_sr_uri_host_extra_chars[i]!='\0') {
53 if(_sr_uri_host_extra_chars[i]==c) {
61 /* buf= pointer to begining of uri (sip:x@foo.bar:5060;a=b?h=i)
63 * returns: fills uri & returns <0 on error or 0 if ok
65 int parse_uri(char* buf, int len, struct sip_uri* uri)
67 enum states { URI_INIT, URI_USER, URI_PASSWORD, URI_PASSWORD_ALPHA,
69 URI_HOST6_P, URI_HOST6_END, URI_PORT,
70 URI_PARAM, URI_PARAM_P, URI_VAL_P, URI_HEADERS,
73 PT_T, PT_R, PT_A, PT_N, PT_S, PT_P, PT_O, PT_R2, PT_T2,
76 PTTL_T2, PTTL_L, PTTL_eq,
78 PU_U, PU_S, PU_E, PU_R, PU_eq,
80 PM_M, PM_E, PM_T, PM_H, PM_O, PM_D, PM_eq,
82 PMA_A, PMA_D, PMA_D2, PMA_R, PMA_eq,
84 PLR_L, PLR_R_FIN, PLR_eq,
86 PR2_R, PR2_2_FIN, PR2_eq,
88 PGR_G, PGR_R_FIN, PGR_eq,
91 PCOMP_C, PCOMP_O, PCOMP_M, PCOMP_P, PCOMP_eq,
95 VCOMP_S, VCOMP_SIGC_I, VCOMP_SIGC_G,
96 VCOMP_SIGC_C, VCOMP_SIGC_O, VCOMP_SIGC_M,
99 VCOMP_SGZ_E, VCOMP_SGZ_R, VCOMP_SGZ_G,
103 /* transport values */
105 VU_U, VU_D, VU_P_FIN,
107 VT_T, VT_C, VT_P_FIN,
111 VS_S, VS_C, VS_T, VS_P_FIN,
115 register enum states state;
117 char* b; /* param start */
118 char *v; /* value start */
119 str* param; /* current param */
120 str* param_val; /* current param val */
130 uri_type backup_urit;
131 uri_flags backup_urif;
134 str comp_str; /* not returned for now */
135 str comp_val; /* not returned for now */
138 #define SIP_SCH 0x3a706973
139 #define SIPS_SCH 0x73706973
140 #define TEL_SCH 0x3a6c6574
141 #define URN_SCH 0x3a6e7275
143 #define case_port( ch, var) \
145 (var)=(var)*10+ch-'0'; \
146 if((var) > MAX_PORT_VAL) { \
147 goto error_bad_port; \
151 #define still_at_user \
152 if (found_user==0){ \
153 user.s=uri->host.s; \
155 user.len=pass-user.s; \
157 password.len=p-password.s; \
161 /* save the uri type/scheme */ \
162 backup_urit=uri->type; \
163 backup_urif=uri->flags; \
164 /* everything else is 0 */ \
165 memset(uri, 0, sizeof(struct sip_uri)); \
166 /* restore the scheme & flags, copy user & pass */ \
167 uri->type=backup_urit; \
168 uri->flags=backup_urif; \
170 if (pass) uri->passwd=password; \
175 }else goto error_bad_char
177 #define check_host_end \
179 /* found the host */ \
202 #define param_set(t_start, v_start) \
204 param->len=(p-(t_start));\
205 param_val->s=(v_start); \
206 param_val->len=(p-(v_start))
208 #define semicolon_case \
211 found_user=1;/* no user, pass cannot contain ';'*/ \
214 state=URI_PARAM /* new param */
216 #define question_case \
219 uri->params.len=p-s; \
223 found_user=1;/* no user, pass cannot contain '?'*/ \
229 if (found_user==0){ \
230 /*might be pass but only if user not found yet*/ \
232 found_user=1; /* no user */ \
238 state=URI_PARAM_P /* generic param */
240 #define param_common_cases \
242 /* ughhh, this is still the user */ \
252 #define value_common_cases \
254 /* ughhh, this is still the user */ \
267 #define param_switch(old_state, c1, c2, new_state) \
274 param_common_cases; \
279 #define param_switch1(old_state, c1, new_state) \
285 param_common_cases; \
290 #define param_switch_big(old_state, c1, c2, d1, d2, new_state_c, new_state_d) \
295 state=(new_state_c); \
299 state=(new_state_d); \
301 param_common_cases; \
306 #define value_switch(old_state, c1, c2, new_state) \
313 value_common_cases; \
318 #define value_switch_big(old_state, c1, c2, d1, d2, new_state_c, new_state_d) \
323 state=(new_state_c); \
327 state=(new_state_d); \
329 value_common_cases; \
335 #define transport_fin(c_state, proto_no) \
343 uri->proto=(proto_no); \
347 uri->proto=(proto_no); \
358 #define comp_fin(c_state, comp_no) \
365 /* param_set(b, v); */ \
366 uri->comp=(comp_no); \
369 /* param_set(b, v) */; \
370 uri->comp=(comp_no); \
389 password.s=0; /* fixes gcc 4.0 warning */
393 memset(uri, 0, sizeof(struct sip_uri)); /* zero it all, just to be sure*/
394 /*look for sip:, sips:, tel: or urn:*/
395 if (len<5) goto error_too_short;
396 scheme=((uint32_t)buf[0]) + (((uint32_t)buf[1])<<8)
397 + (((uint32_t)buf[2])<<16) + (((uint32_t)buf[3])<<24);
399 if (scheme==SIP_SCH){
401 }else if(scheme==SIPS_SCH){
402 if(buf[4]==':'){ p++; uri->type=SIPS_URI_T;}
403 else goto error_bad_uri;
404 }else if (scheme==TEL_SCH){
406 }else if (scheme==URN_SCH){
408 }else goto error_bad_uri;
412 switch((unsigned char)state){
416 /* uri = [ipv6address]... */
421 /* invalid, no uri can start with ']' */
423 /* the same as above for ':' */
425 case '@': /* error no user part, or
426 * be forgiving and accept it ? */
439 s=p+1; /* skip '@' */
442 /* found the user, or the host? */
446 s=p+1; /* skip ':' */
449 /* this could be still the user or
456 case '?': /* still user or headers? */
462 /* almost anything permitted in the user part */
467 /* tel uri visual separators, set flag meaning, that
468 * user should be normalized before usage
470 uri->flags|=URI_USER_NORMALIZE;
473 case ']': /* the user part cannot contain "[]" */
477 case URI_PASSWORD: /* this can also be the port (missing user)*/
480 /* found the password*/
486 s=p+1; /* skip '@' */
489 /* upps this is the port */
492 uri->port_no=port_no;
493 /* user contains in fact the host */
494 uri->host.s=uri->user.s;
495 uri->host.len=uri->user.len;
499 found_user=1; /* there is no user part */
503 /* upps this is the port */
506 uri->port_no=port_no;
507 /* user contains in fact the host */
508 uri->host.s=uri->user.s;
509 uri->host.len=uri->user.len;
513 found_user=1; /* there is no user part */
516 case_port('0', port_no);
517 case_port('1', port_no);
518 case_port('2', port_no);
519 case_port('3', port_no);
520 case_port('4', port_no);
521 case_port('5', port_no);
522 case_port('6', port_no);
523 case_port('7', port_no);
524 case_port('8', port_no);
525 case_port('9', port_no);
531 /* it can't be the port, non number found */
533 state=URI_PASSWORD_ALPHA;
536 case URI_PASSWORD_ALPHA:
539 /* found the password*/
544 s=p+1; /* skip '@' */
546 case ';': /* contains non-numbers => cannot be port no*/
570 if(!isalnum(*p) && (*p != '.') && (*p != '-')
571 && !uri_host_char_allowed(*p)) {
579 default: /*no chars allowed after [ipv6] */
601 uri->port_no=port_no;
608 uri->port_no=port_no;
612 case_port('0', port_no);
613 case_port('1', port_no);
614 case_port('2', port_no);
615 case_port('3', port_no);
616 case_port('4', port_no);
617 case_port('5', port_no);
618 case_port('6', port_no);
619 case_port('7', port_no);
620 case_port('8', port_no);
621 case_port('9', port_no);
629 case URI_PARAM: /* beginning of a new param */
632 /* recognized params */
674 case URI_PARAM_P: /* ignore current param */
676 * maddr, transport, ttl, lr, user, method, r2 */
681 /* ugly but fast param names parsing */
683 param_switch_big(PT_T, 'r', 'R', 't', 'T', PT_R, PTTL_T2);
684 param_switch(PT_R, 'a', 'A', PT_A);
685 param_switch(PT_A, 'n', 'N', PT_N);
686 param_switch(PT_N, 's', 'S', PT_S);
687 param_switch(PT_S, 'p', 'P', PT_P);
688 param_switch(PT_P, 'o', 'O', PT_O);
689 param_switch(PT_O, 'r', 'R', PT_R2);
690 param_switch(PT_R2, 't', 'T', PT_T2);
691 param_switch1(PT_T2, '=', PT_eq);
694 param=&uri->transport;
695 param_val=&uri->transport_val;
730 value_switch(VU_U, 'd', 'D', VU_D);
731 value_switch(VU_D, 'p', 'P', VU_P_FIN);
732 transport_fin(VU_P_FIN, PROTO_UDP);
734 value_switch_big(VT_T, 'c', 'C', 'l', 'L', VT_C, VTLS_L);
735 value_switch(VT_C, 'p', 'P', VT_P_FIN);
736 transport_fin(VT_P_FIN, PROTO_TCP);
738 value_switch(VTLS_L, 's', 'S', VTLS_S_FIN);
739 transport_fin(VTLS_S_FIN, PROTO_TLS);
741 value_switch(VS_S, 'c', 'C', VS_C);
742 value_switch(VS_C, 't', 'T', VS_T);
743 value_switch(VS_T, 'p', 'P', VS_P_FIN);
744 transport_fin(VS_P_FIN, PROTO_SCTP);
746 value_switch(VW_W, 's', 'S', VW_S_FIN);
747 transport_fin(VW_S_FIN, PROTO_WS);
750 param_switch(PTTL_T2, 'l', 'L', PTTL_L);
751 param_switch1(PTTL_L, '=', PTTL_eq);
754 param_val=&uri->ttl_val;
764 param_switch(PU_U, 's', 'S', PU_S);
765 param_switch(PU_S, 'e', 'E', PU_E);
766 param_switch(PU_E, 'r', 'R', PU_R);
767 param_switch1(PU_R, '=', PU_eq);
769 param=&uri->user_param;
770 param_val=&uri->user_param_val;
780 param_switch_big(PM_M, 'e', 'E', 'a', 'A', PM_E, PMA_A);
781 param_switch(PM_E, 't', 'T', PM_T);
782 param_switch(PM_T, 'h', 'H', PM_H);
783 param_switch(PM_H, 'o', 'O', PM_O);
784 param_switch(PM_O, 'd', 'D', PM_D);
785 param_switch1(PM_D, '=', PM_eq);
788 param_val=&uri->method_val;
798 param_switch(PMA_A, 'd', 'D', PMA_D);
799 param_switch(PMA_D, 'd', 'D', PMA_D2);
800 param_switch(PMA_D2, 'r', 'R', PMA_R);
801 param_switch1(PMA_R, '=', PMA_eq);
804 param_val=&uri->maddr_val;
814 param_switch(PLR_L, 'r', 'R', PLR_R_FIN);
837 /* handle lr=something case */
840 param_val=&uri->lr_val;
849 param_switch1(PR2_R, '2', PR2_2_FIN);
872 /* handle lr=something case */
875 param_val=&uri->r2_val;
884 param_switch(PGR_G, 'r', 'R', PGR_R_FIN);
907 /* handle gr=something case */
910 param_val=&uri->gr_val;
920 param_switch(PCOMP_C, 'o', 'O' , PCOMP_O);
921 param_switch(PCOMP_O, 'm', 'M' , PCOMP_M);
922 param_switch(PCOMP_M, 'p', 'P' , PCOMP_P);
923 param_switch1(PCOMP_P, '=', PCOMP_eq);
941 value_switch_big(VCOMP_S, 'i', 'I', 'e', 'E',
942 VCOMP_SIGC_I, VCOMP_SGZ_E);
943 value_switch(VCOMP_SIGC_I, 'g', 'G', VCOMP_SIGC_G);
944 value_switch(VCOMP_SIGC_G, 'c', 'C', VCOMP_SIGC_C);
945 value_switch(VCOMP_SIGC_C, 'o', 'O', VCOMP_SIGC_O);
946 value_switch(VCOMP_SIGC_O, 'm', 'M', VCOMP_SIGC_M);
947 value_switch(VCOMP_SIGC_M, 'p', 'P', VCOMP_SIGC_P_FIN);
948 comp_fin(VCOMP_SIGC_P_FIN, COMP_SIGCOMP);
951 value_switch(VCOMP_SGZ_E, 'r', 'R', VCOMP_SGZ_R);
952 value_switch(VCOMP_SGZ_R, 'g', 'G', VCOMP_SGZ_G);
953 value_switch(VCOMP_SGZ_G, 'z', 'Z', VCOMP_SGZ_Z_FIN);
954 comp_fin(VCOMP_SGZ_Z_FIN, COMP_SERGZ);
959 /* for now nobody needs them so we completely ignore the
960 * headers (they are not allowed in request uri) --andrei */
963 /* yak, we are still at user */
967 /* we might be still parsing user, try it */
968 if (found_user) goto error_bad_char;
969 error_headers=1; /* if this is not the user
971 /* if pass is set => it cannot be user:pass
972 * => error (';') is illegal in a header */
973 if (pass) goto error_headers;
977 /*might be pass but only if user not found yet*/
979 found_user=1; /* no user */
988 found_user=1; /* no user, pass cannot contain '?'*/
1000 case URI_INIT: /* error empty uri */
1001 goto error_too_short;
1003 /* this is the host, it can't be the user */
1004 if (found_user) goto error_bad_uri;
1010 /* this is the port, it can't be the passwd */
1011 if (found_user) goto error_bad_port;
1014 uri->port_no=port_no;
1015 uri->host=uri->user;
1019 case URI_PASSWORD_ALPHA:
1020 /* it might be an urn, check scheme and set host */
1021 if (scheme==URN_SCH){
1024 LM_DBG("parsed urn scheme with host: %.*s\n",
1025 uri->host.len, uri->host.s);
1026 /* this is the port, it can't be the passwd */
1027 }else goto error_bad_port;
1034 case URI_HOST: /* error: null host */
1035 case URI_HOST6_P: /* error: unterminated ipv6 reference*/
1036 goto error_bad_host;
1040 uri->port_no=port_no;
1044 /* intermediate param states */
1045 case PT_T: /* transport */
1054 case PT_eq: /* ignore empty transport params */
1055 case PTTL_T2: /* ttl */
1058 case PU_U: /* user */
1063 case PM_M: /* method */
1070 case PLR_L: /* lr */
1071 case PR2_R: /* r2 */
1072 case PGR_G: /* gr */
1081 uri->params.len=p-s;
1083 /* fin param states */
1087 uri->params.len=p-s;
1094 uri->params.len=p-s;
1101 uri->params.len=p-s;
1106 /* intermediate value states */
1117 uri->params.len=p-s;
1130 /* unrecognized comp method, assume none */
1132 uri->params.len=p-s;
1133 /* uri->comp=COMP_NONE ; */
1136 /* fin value states */
1139 uri->params.len=p-s;
1141 uri->proto=PROTO_UDP;
1145 uri->params.len=p-s;
1147 uri->proto=PROTO_TCP;
1151 uri->params.len=p-s;
1153 uri->proto=PROTO_TLS;
1157 uri->params.len=p-s;
1159 uri->proto=PROTO_SCTP;
1163 uri->params.len=p-s;
1165 uri->proto=PROTO_WS;
1168 case VCOMP_SIGC_P_FIN:
1170 uri->params.len=p-s;
1171 /* param_set(b, v); */
1172 uri->comp=COMP_SIGCOMP;
1174 case VCOMP_SGZ_Z_FIN:
1176 uri->params.len=p-s;
1177 /* param_set(b, v); */
1178 uri->comp=COMP_SERGZ;
1184 uri->headers.len=p-s;
1185 if (error_headers) goto error_headers;
1193 /* save the original sip: URI parameters in sip_params */
1194 uri->sip_params=uri->params;
1196 (uri->user_param_val.len == 5) &&
1197 (strncmp(uri->user_param_val.s, "phone", 5) == 0)
1199 uri->type = TEL_URI_T;
1200 uri->flags |= URI_SIP_USER_PHONE;
1201 /* move params from user into uri->params */
1202 p=q_memchr(uri->user.s, ';', uri->user.len);
1205 * specialized uri params (user, maddr, etc.) still hold
1206 * the values from the sip-uri envelope
1207 * while uri->params point to the params in the embedded tel uri
1210 uri->params.len=uri->user.s+uri->user.len-uri->params.s;
1211 uri->user.len=p-uri->user.s;
1217 uri->flags&=~URI_USER_NORMALIZE;
1222 /* fix tel uris, move the number in uri and empty the host */
1223 uri->user=uri->host;
1224 uri->host=_sr_uri_empty;
1226 /* urn: do nothing */
1230 LM_ERR("parse uri unexpected error (BUG?)\n");
1232 break; /* do nothing, avoids a compilation warning */
1236 goto error_invalid_port;
1240 LM_DBG("parsed uri:\n type=%d user=<%.*s>(%d)\n passwd=<%.*s>(%d)\n"
1241 " host=<%.*s>(%d)\n port=<%.*s>(%d): %d\n params=<%.*s>(%d)\n"
1242 " headers=<%.*s>(%d)\n",
1244 uri->user.len, ZSW(uri->user.s), uri->user.len,
1245 uri->passwd.len, ZSW(uri->passwd.s), uri->passwd.len,
1246 uri->host.len, ZSW(uri->host.s), uri->host.len,
1247 uri->port.len, ZSW(uri->port.s), uri->port.len, uri->port_no,
1248 uri->params.len, ZSW(uri->params.s), uri->params.len,
1249 uri->headers.len, ZSW(uri->headers.s), uri->headers.len
1251 LM_DBG(" uri flags : ");
1252 if (uri->flags & URI_USER_NORMALIZE) LM_DBG("user_need_norm ");
1253 if (uri->flags & URI_SIP_USER_PHONE) LM_DBG("sip_user_phone ");
1254 LM_DBG(" value=%d\n",uri->flags);
1255 LM_DBG(" uri params:\n transport=<%.*s>, val=<%.*s>, proto=%d\n",
1256 uri->transport.len, ZSW(uri->transport.s), uri->transport_val.len,
1257 ZSW(uri->transport_val.s), uri->proto);
1258 LM_DBG(" user-param=<%.*s>, val=<%.*s>\n",
1259 uri->user_param.len, ZSW(uri->user_param.s),
1260 uri->user_param_val.len, ZSW(uri->user_param_val.s));
1261 LM_DBG(" method=<%.*s>, val=<%.*s>\n",
1262 uri->method.len, ZSW(uri->method.s),
1263 uri->method_val.len, ZSW(uri->method_val.s));
1264 LM_DBG(" ttl=<%.*s>, val=<%.*s>\n",
1265 uri->ttl.len, ZSW(uri->ttl.s),
1266 uri->ttl_val.len, ZSW(uri->ttl_val.s));
1267 LM_DBG(" maddr=<%.*s>, val=<%.*s>\n",
1268 uri->maddr.len, ZSW(uri->maddr.s),
1269 uri->maddr_val.len, ZSW(uri->maddr_val.s));
1270 LM_DBG(" lr=<%.*s>\n", uri->lr.len, ZSW(uri->lr.s));
1271 LM_DBG(" r2=<%.*s>\n", uri->r2.len, ZSW(uri->r2.s));
1273 LM_DBG(" comp=%d\n", uri->comp);
1280 LM_DBG("uri too short: <%.*s> (%d)\n",
1281 len, ZSW(buf), len);
1284 LM_DBG("bad char '%c' in state %d"
1285 " parsed: <%.*s> (%d) / <%.*s> (%d)\n",
1286 *p, state, (int)(p-buf), ZSW(buf), (int)(p-buf),
1287 len, ZSW(buf), len);
1290 LM_DBG("bad host in uri (error at char %c in"
1291 " state %d) parsed: <%.*s>(%d) /<%.*s> (%d)\n",
1292 *p, state, (int)(p-buf), ZSW(buf), (int)(p-buf),
1293 len, ZSW(buf), len);
1296 LM_DBG("bad port in uri (error at char %c in"
1297 " state %d) parsed: <%.*s>(%d) /<%.*s> (%d)\n",
1298 *p, state, (int)(p-buf), ZSW(buf), (int)(p-buf),
1299 len, ZSW(buf), len);
1302 LM_DBG("bad port in uri: [%.*s] in <%.*s>\n",
1303 uri->port.len, uri->port.s, len, ZSW(buf));
1306 LM_DBG("bad uri, state %d parsed: <%.*s> (%d) / <%.*s> (%d)\n",
1307 state, (int)(p-buf), ZSW(buf), (int)(p-buf), len,
1311 LM_DBG("bad uri headers: <%.*s>(%d) / <%.*s>(%d)\n",
1312 uri->headers.len, ZSW(uri->headers.s), uri->headers.len,
1313 len, ZSW(buf), len);
1316 LM_CRIT("BUG: bad state %d parsed: <%.*s> (%d) / <%.*s> (%d)\n",
1317 state, (int)(p-buf), ZSW(buf), (int)(p-buf), len, ZSW(buf), len);
1319 ser_error=E_BAD_URI;
1320 uri->type=ERROR_URI_T;
1326 static inline int _parse_ruri(str *uri,
1327 int *status, struct sip_uri *parsed_uri)
1329 if (*status) return 1;
1331 if (parse_uri(uri->s, uri->len, parsed_uri)<0) {
1332 LM_ERR("bad uri <%.*s>\n", uri->len, ZSW(uri->s));
1340 int parse_sip_msg_uri(struct sip_msg* msg)
1344 if (msg->parsed_uri_ok) return 1;
1346 if (msg->new_uri.s){
1348 tmp_len=msg->new_uri.len;
1350 tmp=msg->first_line.u.request.uri.s;
1351 tmp_len=msg->first_line.u.request.uri.len;
1353 if (parse_uri(tmp, tmp_len, &msg->parsed_uri)<0){
1354 LM_DBG("bad uri <%.*s>\n", tmp_len, tmp);
1355 msg->parsed_uri_ok=0;
1358 msg->parsed_uri_ok=1;
1362 int parse_orig_ruri(struct sip_msg* msg)
1366 ret=_parse_ruri(&REQ_LINE(msg).uri,
1367 &msg->parsed_orig_ruri_ok, &msg->parsed_orig_ruri);
1368 if (ret<0) LM_ERR("parse orig ruri failed\n");
1372 int normalize_tel_user(char* res, str* src)
1376 for (i=0; i<src->len; i++) {
1377 switch (src->s[i]) {
1391 str s_sip = STR_STATIC_INIT("sip");
1392 str s_sips = STR_STATIC_INIT("sips");
1393 str s_tel = STR_STATIC_INIT("tel");
1394 str s_tels = STR_STATIC_INIT("tels");
1395 str s_urn = STR_STATIC_INIT("urn");
1396 static str s_null = STR_STATIC_INIT("");
1398 void uri_type_to_str(uri_type type, str *s) {
1420 static str s_udp = STR_STATIC_INIT("udp");
1421 static str s_tcp = STR_STATIC_INIT("tcp");
1422 static str s_tls = STR_STATIC_INIT("tls");
1423 static str s_sctp = STR_STATIC_INIT("sctp");
1424 static str s_ws = STR_STATIC_INIT("ws");
1426 void proto_type_to_str(unsigned short type, str *s) {