Commit 40f0cd3a authored by Pekka Pessi's avatar Pekka Pessi

Fixed bug in sip_transport_d() parsing different tls transports.

This bug affected mainly parsing futuristic Via headers.

darcs-hash:20060316133829-65a35-8f7523966026f607e76fcfb19721d7c2bfe0f9b3.gz
parent cc579862
......@@ -367,8 +367,9 @@ int sip_transport_d(char **ss, char const **ttransport)
int pn_len, pv_len, pt_len;
char *s = *ss;
#define TRANSPORT_MATCH(t) \
(strncasecmp(s+7,t+7,sizeof(t)-8) == 0 && (transport = t, s += sizeof(t) - 1))
#define TRANSPORT_MATCH(t) \
(strncasecmp(s+7, t+7, sizeof(t)-8) == 0 && (IS_LWS(s[sizeof(t)])) \
&& (transport = t, s += sizeof(t) - 1))
if (strncasecmp(s, "SIP/2.0", 7) != 0 ||
(!TRANSPORT_MATCH(sip_transport_udp) &&
......
......@@ -186,7 +186,40 @@ int test_methods(void)
TEST_S(result, "protocol/version");
}
{
char udp[] = "SIP/ 2.0 / udp";
char tcp[] = "SIP / 2.0 / tcp";
char tls[] = "SIP / 2.0 / tls";
char sctp[] = "SIP / 2.0 / scTp";
char dtls[] = "SIP/2.0/TLS-UDP";
char tls_sctp[] = "SIP/2.0/TLS-SCTP";
char *s, *end;
char const *result = NULL;
s = udp; end = s + strlen(s);
TEST(sip_transport_d(&s, &result), 0); TEST(s, end);
TEST_S(result, sip_transport_udp);
s = tcp; end = s + strlen(s);
TEST(sip_transport_d(&s, &result), 0); TEST(s, end);
TEST_S(result, sip_transport_tcp);
s = tls; end = s + strlen(s);
TEST(sip_transport_d(&s, &result), 0); TEST(s, end);
TEST_S(result, sip_transport_tls);
s = sctp; end = s + strlen(s);
TEST(sip_transport_d(&s, &result), 0); TEST(s, end);
TEST_S(result, sip_transport_sctp);
s = dtls; end = s + strlen(s);
TEST(sip_transport_d(&s, &result), 0); TEST(s, end);
TEST_S(result, "SIP/2.0/TLS-UDP");
s = tls_sctp; end = s + strlen(s);
TEST(sip_transport_d(&s, &result), 0); TEST(s, end);
TEST_S(result, "SIP/2.0/TLS-SCTP");
}
END();
}
......@@ -440,6 +473,21 @@ int test_basic(void)
su_free(home, m0);
}
{
sip_via_t *v;
char *s;
v = sip_via_make(home, "SIP/2.0/UDP domain.invalid:5060"); TEST_1(v);
s = sip_contact_string_from_via(home, v, NULL, v->v_protocol);
TEST_S(s, "<sip:domain.invalid:5060;transport=udp>");
su_free(home, v), su_free(home, s);
v = sip_via_make(home, "SIP/2.0/TLS-SCTP domain.invalid"); TEST_1(v);
s = sip_contact_string_from_via(home, v, NULL, v->v_protocol);
TEST_S(s, "<sips:domain.invalid;transport=tls-sctp>");
su_free(home, v), su_free(home, s);
}
{
sip_expires_t *ex;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment