... | ... |
@@ -63,6 +63,9 @@ inline static enum sip_protos get_proto(enum sip_protos force_proto, |
63 | 63 |
case PROTO_UDP: /* transport specified explicitely */ |
64 | 64 |
#ifdef USE_TCP |
65 | 65 |
case PROTO_TCP: |
66 |
+#endif |
|
67 |
+#ifdef USE_TLS |
|
68 |
+ case PROTO_TLS: |
|
66 | 69 |
#endif |
67 | 70 |
return u->proto; |
68 | 71 |
default: |
... | ... |
@@ -73,6 +76,9 @@ inline static enum sip_protos get_proto(enum sip_protos force_proto, |
73 | 76 |
case PROTO_UDP: /* some protocol has been forced -- take it */ |
74 | 77 |
#ifdef USE_TCP |
75 | 78 |
case PROTO_TCP: |
79 |
+#endif |
|
80 |
+#ifdef USE_TLS |
|
81 |
+ case PROTO_TLS: |
|
76 | 82 |
#endif |
77 | 83 |
return force_proto; |
78 | 84 |
default: |
... | ... |
@@ -1174,6 +1174,8 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg, |
1174 | 1174 |
" id_builder failed\n"); |
1175 | 1175 |
goto error01; /* free everything */ |
1176 | 1176 |
} |
1177 |
+ DBG("build_req_from_req: id added: <%.*s>, rcv proto=%d\n", |
|
1178 |
+ id_len, id_buf, msg->rcv.proto); |
|
1177 | 1179 |
extra_params.s=id_buf; |
1178 | 1180 |
extra_params.len=id_len; |
1179 | 1181 |
} |
... | ... |
@@ -1183,6 +1185,8 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg, |
1183 | 1185 |
|| proto==PROTO_TLS |
1184 | 1186 |
#endif |
1185 | 1187 |
){ |
1188 |
+ DBG("build_req_from_req: checking for clen; proto=%d, rcv->proto=%d\n", |
|
1189 |
+ proto, msg->rcv.proto); |
|
1186 | 1190 |
/* first of all parse content-length */ |
1187 | 1191 |
if (parse_headers(msg, HDR_CONTENTLENGTH, 0)==-1){ |
1188 | 1192 |
LOG(L_ERR, "build_req_buf_from_sip_req:" |
... | ... |
@@ -1885,7 +1889,7 @@ char* via_builder( unsigned int *len, |
1885 | 1889 |
}else if (proto==PROTO_TCP){ |
1886 | 1890 |
memcpy(line_buf+MY_VIA_LEN-4, "TCP ", 4); |
1887 | 1891 |
}else if (proto==PROTO_TLS){ |
1888 |
- memcpy(line_buf+MY_VIA_LEN-4, "TLS", 4); |
|
1892 |
+ memcpy(line_buf+MY_VIA_LEN-4, "TLS ", 4); |
|
1889 | 1893 |
}else{ |
1890 | 1894 |
LOG(L_CRIT, "BUG: via_builder: unknown proto %d\n", proto); |
1891 | 1895 |
return 0; |
... | ... |
@@ -43,6 +43,7 @@ |
43 | 43 |
* 2003-02-28 scratchpad compatibility abandoned (jiri) |
44 | 44 |
* 2003-04-26 ZSW (jiri) |
45 | 45 |
* 2003-06-23 fixed parse_via_param [op].* param. parsing bug (andrei) |
46 |
+ * 2003-07-02 added support for TLS parsing in via (andrei) |
|
46 | 47 |
*/ |
47 | 48 |
|
48 | 49 |
|
... | ... |
@@ -81,7 +82,8 @@ enum { |
81 | 82 |
L_VER, F_VER, |
82 | 83 |
VER1, VER2, FIN_VER, |
83 | 84 |
UDP1, UDP2, FIN_UDP, |
84 |
- TCP1, TCP2, FIN_TCP, |
|
85 |
+ TCP_TLS1, TCP2, FIN_TCP, |
|
86 |
+ TLS2, FIN_TLS, |
|
85 | 87 |
L_PROTO, F_PROTO |
86 | 88 |
}; |
87 | 89 |
|
... | ... |
@@ -985,6 +987,12 @@ parse_again: |
985 | 987 |
vb->proto=PROTO_TCP; |
986 | 988 |
state=F_HOST; /* start looking for host*/ |
987 | 989 |
goto main_via; |
990 |
+ case FIN_TLS: |
|
991 |
+ /* finished proto parsing */ |
|
992 |
+ vb->transport.len=tmp-vb->transport.s; |
|
993 |
+ vb->proto=PROTO_TLS; |
|
994 |
+ state=F_HOST; /* start looking for host*/ |
|
995 |
+ goto main_via; |
|
988 | 996 |
case FIN_SIP: |
989 | 997 |
vb->name.len=tmp-vb->name.s; |
990 | 998 |
state=L_VER; |
... | ... |
@@ -1026,6 +1034,12 @@ parse_again: |
1026 | 1034 |
state=F_LF; |
1027 | 1035 |
saved_state=F_HOST; /* start looking for host*/ |
1028 | 1036 |
goto main_via; |
1037 |
+ case FIN_TLS: |
|
1038 |
+ vb->transport.len=tmp-vb->transport.s; |
|
1039 |
+ vb->proto=PROTO_TLS; |
|
1040 |
+ state=F_LF; |
|
1041 |
+ saved_state=F_HOST; /* start looking for host*/ |
|
1042 |
+ goto main_via; |
|
1029 | 1043 |
case FIN_SIP: |
1030 | 1044 |
vb->name.len=tmp-vb->name.s; |
1031 | 1045 |
state=F_LF; |
... | ... |
@@ -1071,6 +1085,12 @@ parse_again: |
1071 | 1085 |
state=F_CR; |
1072 | 1086 |
saved_state=F_HOST; |
1073 | 1087 |
goto main_via; |
1088 |
+ case FIN_TLS: |
|
1089 |
+ vb->transport.len=tmp-vb->transport.s; |
|
1090 |
+ vb->proto=PROTO_TLS; |
|
1091 |
+ state=F_CR; |
|
1092 |
+ saved_state=F_HOST; |
|
1093 |
+ goto main_via; |
|
1074 | 1094 |
case FIN_SIP: |
1075 | 1095 |
vb->name.len=tmp-vb->name.s; |
1076 | 1096 |
state=F_CR; |
... | ... |
@@ -1123,6 +1143,9 @@ parse_again: |
1123 | 1143 |
state=SIP1; |
1124 | 1144 |
vb->name.s=tmp; |
1125 | 1145 |
break; |
1146 |
+ case TLS2: |
|
1147 |
+ state=FIN_TLS; |
|
1148 |
+ break; |
|
1126 | 1149 |
default: |
1127 | 1150 |
LOG(L_ERR, "ERROR: parse_via: bad char <%c> on" |
1128 | 1151 |
" state %d\n", *tmp, state); |
... | ... |
@@ -1189,7 +1212,7 @@ parse_again: |
1189 | 1212 |
case 't': |
1190 | 1213 |
switch(state){ |
1191 | 1214 |
case F_PROTO: |
1192 |
- state=TCP1; |
|
1215 |
+ state=TCP_TLS1; |
|
1193 | 1216 |
vb->transport.s=tmp; |
1194 | 1217 |
break; |
1195 | 1218 |
default: |
... | ... |
@@ -1201,7 +1224,7 @@ parse_again: |
1201 | 1224 |
case 'C': |
1202 | 1225 |
case 'c': |
1203 | 1226 |
switch(state){ |
1204 |
- case TCP1: |
|
1227 |
+ case TCP_TLS1: |
|
1205 | 1228 |
state=TCP2; |
1206 | 1229 |
break; |
1207 | 1230 |
default: |
... | ... |
@@ -1210,6 +1233,18 @@ parse_again: |
1210 | 1233 |
goto error; |
1211 | 1234 |
} |
1212 | 1235 |
break; |
1236 |
+ case 'L': |
|
1237 |
+ case 'l': |
|
1238 |
+ switch(state){ |
|
1239 |
+ case TCP_TLS1: |
|
1240 |
+ state=TLS2; |
|
1241 |
+ break; |
|
1242 |
+ default: |
|
1243 |
+ LOG(L_ERR, "ERROR: parse_via: bad char <%c> on" |
|
1244 |
+ " state %d\n", *tmp, state); |
|
1245 |
+ goto error; |
|
1246 |
+ } |
|
1247 |
+ break; |
|
1213 | 1248 |
/*match 2.0*/ |
1214 | 1249 |
case '2': |
1215 | 1250 |
switch(state){ |
... | ... |
@@ -497,6 +497,11 @@ struct hostent* sip_resolvehost(str* name, unsigned short* port, int proto) |
497 | 497 |
memcpy(tmp+SRV_PREFIX_LEN, name->s, name->len); |
498 | 498 |
tmp[SRV_PREFIX_LEN + name->len] = '\0'; |
499 | 499 |
break; |
500 |
+ case PROTO_TLS: |
|
501 |
+ memcpy(tmp, SRV_TLS_PREFIX, SRV_PREFIX_LEN); |
|
502 |
+ memcpy(tmp+SRV_PREFIX_LEN, name->s, name->len); |
|
503 |
+ tmp[SRV_PREFIX_LEN + name->len] = '\0'; |
|
504 |
+ break; |
|
500 | 505 |
default: |
501 | 506 |
LOG(L_CRIT, "BUG: sip_resolvehost: unknown proto %d\n", |
502 | 507 |
proto); |
... | ... |
@@ -141,7 +141,6 @@ struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su, |
141 | 141 |
c->refcnt=0; |
142 | 142 |
su2ip_addr(&c->rcv.src_ip, su); |
143 | 143 |
c->rcv.src_port=su_getport(su); |
144 |
- c->rcv.proto=PROTO_TCP; |
|
145 | 144 |
c->rcv.bind_address=ba; |
146 | 145 |
if (ba){ |
147 | 146 |
c->rcv.dst_ip=ba->address; |
... | ... |
@@ -793,7 +792,7 @@ void tcp_main_loop() |
793 | 792 |
/* start from 1, the "main" process does not transmit anything*/ |
794 | 793 |
for (r=1; r<process_no && n; r++){ |
795 | 794 |
if ( (pt[r].unix_sock>0) && FD_ISSET(pt[r].unix_sock, &sel_set)){ |
796 |
- /* (we can't have a fd==0, 0 i s never closed )*/ |
|
795 |
+ /* (we can't have a fd==0, 0 is never closed )*/ |
|
797 | 796 |
n--; |
798 | 797 |
/* errno==EINTR !!! TODO*/ |
799 | 798 |
read_again: |
... | ... |
@@ -399,14 +399,14 @@ int tcp_read_req(struct tcp_connection* con) |
399 | 399 |
#ifdef USE_TLS |
400 | 400 |
if (con->type==PROTO_TLS){ |
401 | 401 |
if (con->state==S_CONN_ACCEPT){ |
402 |
- if (tls_accept(con)!=0){ |
|
402 |
+ if (tls_accept(con, 0)!=0){ |
|
403 | 403 |
resp=CONN_ERROR; |
404 | 404 |
goto end_req; |
405 | 405 |
} |
406 | 406 |
if(con->state!=S_CONN_OK) goto end_req; /* not enough data */ |
407 | 407 |
} |
408 | 408 |
if(con->state==S_CONN_CONNECT){ |
409 |
- if (tls_connect(con)!=0){ |
|
409 |
+ if (tls_connect(con, 0)!=0){ |
|
410 | 410 |
resp=CONN_ERROR; |
411 | 411 |
goto end_req; |
412 | 412 |
} |
... | ... |
@@ -1,4 +1,4 @@ |
1 |
-INVITE sip:p2@195.37.78.126 SIP/2.0 |
|
1 |
+INVITE sip:p2@iptel.org SIP/2.0 |
|
2 | 2 |
Via: SIP/2.0/UDP 192.168.99.100:5040 |
3 | 3 |
From: "GMD FOKUS iptlab" <sip:jiri@iptel.org>;tag=b96b0300ed30f1286-2f5d |
4 | 4 |
Call-ID: b96b0300-88d30f-66da-63aa@195.37.78.190 |
... | ... |
@@ -9,7 +9,7 @@ User-Agent: Cisco-SIP-IP-Phone/2 |
9 | 9 |
Accept: application/sdp |
10 | 10 |
Contact: sip:jiri@195.37.78.190:5060 |
11 | 11 |
Content-Type: application/sdp |
12 |
-Content-Length: 225 |
|
12 |
+Content-Length: 218 |
|
13 | 13 |
|
14 | 14 |
|
15 | 15 |
v=0 |