summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/account.c18
-rw-r--r--src/call.c18
-rw-r--r--src/core.h2
-rw-r--r--src/message.c11
-rw-r--r--src/sdp.c8
-rw-r--r--src/ua.c4
6 files changed, 30 insertions, 31 deletions
diff --git a/src/account.c b/src/account.c
index 95ceeba..b8945b1 100644
--- a/src/account.c
+++ b/src/account.c
@@ -43,7 +43,7 @@ static int param_dstr(char **dstr, const struct pl *params, const char *name)
{
struct pl pl;
- if (sip_param_decode(params, name, &pl))
+ if (msg_param_decode(params, name, &pl))
return 0;
return pl_strdup(dstr, &pl);
@@ -54,7 +54,7 @@ static int param_u32(uint32_t *v, const struct pl *params, const char *name)
{
struct pl pl;
- if (sip_param_decode(params, name, &pl))
+ if (msg_param_decode(params, name, &pl))
return 0;
*v = pl_u32(&pl);
@@ -74,7 +74,7 @@ static int stunsrv_decode(struct account *acc, const struct sip_addr *aor)
memset(&uri, 0, sizeof(uri));
- if (0 == sip_param_decode(&aor->params, "stunserver", &srv)) {
+ if (0 == msg_param_decode(&aor->params, "stunserver", &srv)) {
info("using stunserver: '%r'\n", &srv);
@@ -134,7 +134,7 @@ static void answermode_decode(struct account *prm, const struct pl *pl)
{
struct pl amode;
- if (0 == sip_param_decode(pl, "answermode", &amode)) {
+ if (0 == msg_param_decode(pl, "answermode", &amode)) {
if (0 == pl_strcasecmp(&amode, "manual")) {
prm->answermode = ANSWERMODE_MANUAL;
@@ -180,12 +180,12 @@ static int audio_codecs_decode(struct account *acc, const struct pl *prm)
list_init(&acc->aucodecl);
- if (0 == sip_param_exists(prm, "audio_codecs", &tmp)) {
+ if (0 == msg_param_exists(prm, "audio_codecs", &tmp)) {
struct pl acs;
char cname[64];
unsigned i = 0;
- if (sip_param_decode(prm, "audio_codecs", &acs))
+ if (msg_param_decode(prm, "audio_codecs", &acs))
return 0;
while (0 == csl_parse(&acs, cname, sizeof(cname))) {
@@ -236,12 +236,12 @@ static int video_codecs_decode(struct account *acc, const struct pl *prm)
list_init(&acc->vidcodecl);
- if (0 == sip_param_exists(prm, "video_codecs", &tmp)) {
+ if (0 == msg_param_exists(prm, "video_codecs", &tmp)) {
struct pl vcs;
char cname[64];
unsigned i = 0;
- if (sip_param_decode(prm, "video_codecs", &vcs))
+ if (msg_param_decode(prm, "video_codecs", &vcs))
return 0;
while (0 == csl_parse(&vcs, cname, sizeof(cname))) {
@@ -298,7 +298,7 @@ static int sip_params_decode(struct account *acc, const struct sip_addr *aor)
err |= param_dstr(&acc->sipnat, &aor->params, "sipnat");
- if (0 == sip_param_decode(&aor->params, "auth_user", &auth_user))
+ if (0 == msg_param_decode(&aor->params, "auth_user", &auth_user))
err |= pl_strdup(&acc->auth_user, &auth_user);
else
err |= pl_strdup(&acc->auth_user, &aor->uri.user);
diff --git a/src/call.c b/src/call.c
index dc3edb5..5708608 100644
--- a/src/call.c
+++ b/src/call.c
@@ -954,7 +954,8 @@ static int sipsess_answer_handler(const struct sip_msg *msg, void *arg)
MAGIC_CHECK(call);
- (void)sdp_decode_multipart(&msg->ctype, msg->mb);
+ if (msg_ctype_cmp(&msg->ctyp, "multipart", "mixed"))
+ (void)sdp_decode_multipart(&msg->ctyp.params, msg->mb);
err = sdp_decode(call->sdp, msg->mb, false);
if (err) {
@@ -1030,7 +1031,7 @@ static void sipsess_info_handler(struct sip *sip, const struct sip_msg *msg,
{
struct call *call = arg;
- if (!pl_strcasecmp(&msg->ctype, "application/dtmf-relay")) {
+ if (msg_ctype_cmp(&msg->ctyp, "application", "dtmf-relay")) {
struct pl body, sig, dur;
int err;
@@ -1063,8 +1064,8 @@ static void sipsess_info_handler(struct sip *sip, const struct sip_msg *msg,
}
}
#ifdef USE_VIDEO
- else if (!pl_strcasecmp(&msg->ctype,
- "application/media_control+xml")) {
+ else if (msg_ctype_cmp(&msg->ctyp,
+ "application", "media_control+xml")) {
call_handle_info_req(call, msg);
(void)sip_reply(sip, msg, 200, "OK");
}
@@ -1227,8 +1228,8 @@ static void sipsess_progr_handler(const struct sip_msg *msg, void *arg)
MAGIC_CHECK(call);
- info("call: SIP Progress: %u %r (%r)\n",
- msg->scode, &msg->reason, &msg->ctype);
+ info("call: SIP Progress: %u %r (%r/%r)\n",
+ msg->scode, &msg->reason, &msg->ctyp.type, &msg->ctyp.subtype);
if (msg->scode <= 100)
return;
@@ -1241,12 +1242,13 @@ static void sipsess_progr_handler(const struct sip_msg *msg, void *arg)
* we must also handle changes to/from 180 and 183,
* so we reset the media-stream/ringback each time.
*/
- if (!pl_strcasecmp(&msg->ctype, "application/sdp")
+ if (msg_ctype_cmp(&msg->ctyp, "application", "sdp")
&& mbuf_get_left(msg->mb)
&& !sdp_decode(call->sdp, msg->mb, false)) {
media = true;
}
- else if (!sdp_decode_multipart(&msg->ctype, msg->mb) &&
+ else if (msg_ctype_cmp(&msg->ctyp, "multipart", "mixed") &&
+ !sdp_decode_multipart(&msg->ctyp.params, msg->mb) &&
!sdp_decode(call->sdp, msg->mb, false)) {
media = true;
}
diff --git a/src/core.h b/src/core.h
index 9b92b4b..2f8784b 100644
--- a/src/core.h
+++ b/src/core.h
@@ -283,7 +283,7 @@ int sip_req_send(struct ua *ua, const char *method, const char *uri,
* SDP
*/
-int sdp_decode_multipart(const struct pl *ctype, struct mbuf *mb);
+int sdp_decode_multipart(const struct pl *ctype_prm, struct mbuf *mb);
const struct sdp_format *sdp_media_format_cycle(struct sdp_media *m);
diff --git a/src/message.c b/src/message.c
index b0e33e1..9d3662b 100644
--- a/src/message.c
+++ b/src/message.c
@@ -15,15 +15,12 @@ static void *recvarg;
static void handle_message(struct ua *ua, const struct sip_msg *msg)
{
- static const char *ctype_text = "text/plain";
- struct pl mtype;
+ static const char ctype_text[] = "text/plain";
+ struct pl ctype_pl = {ctype_text, sizeof(ctype_text)-1};
(void)ua;
- if (re_regex(msg->ctype.p, msg->ctype.l, "[^;]+", &mtype))
- mtype = msg->ctype;
-
- if (0==pl_strcasecmp(&mtype, ctype_text) && recvh) {
- recvh(&msg->from.auri, &msg->ctype, msg->mb, recvarg);
+ if (msg_ctype_cmp(&msg->ctyp, "text", "plain") && recvh) {
+ recvh(&msg->from.auri, &ctype_pl, msg->mb, recvarg);
(void)sip_reply(uag_sip(), msg, 200, "OK");
}
else {
diff --git a/src/sdp.c b/src/sdp.c
index 7a8ed29..8001253 100644
--- a/src/sdp.c
+++ b/src/sdp.c
@@ -145,18 +145,18 @@ static void decode_part(const struct pl *part, struct mbuf *mb)
/**
* Decode a multipart/mixed message and find the part with application/sdp
*/
-int sdp_decode_multipart(const struct pl *ctype, struct mbuf *mb)
+int sdp_decode_multipart(const struct pl *ctype_prm, struct mbuf *mb)
{
struct pl bnd, s, e, p;
char expr[64];
int err;
- if (!ctype || !mb)
+ if (!ctype_prm || !mb)
return EINVAL;
/* fetch the boundary tag, excluding quotes */
- err = re_regex(ctype->p, ctype->l,
- "multipart/mixed;[ \t]*boundary=[~]+", NULL, &bnd);
+ err = re_regex(ctype_prm->p, ctype_prm->l,
+ "boundary=[~]+", &bnd);
if (err)
return err;
diff --git a/src/ua.c b/src/ua.c
index cb99011..6d66ca4 100644
--- a/src/ua.c
+++ b/src/ua.c
@@ -1424,14 +1424,14 @@ struct ua *uag_find_param(const char *name, const char *value)
if (value) {
- if (0 == sip_param_decode(&laddr->params, name, &val)
+ if (0 == msg_param_decode(&laddr->params, name, &val)
&&
0 == pl_strcasecmp(&val, value)) {
return ua;
}
}
else {
- if (0 == sip_param_exists(&laddr->params, name, &val))
+ if (0 == msg_param_exists(&laddr->params, name, &val))
return ua;
}
}