Skip to content

Commit 287766f

Browse files
committed
ua: check offerred media AF already at sipsess_conn_handler()
Checking if offered media AF of incoming call is supported and available, needs to be done already in ua.c sipsess_conn_handler(). It is too late if checking is done in ua.c call_alloc(): ``` ua: using AF from sdp offer: af=AF_INET ua: SDP offer AF not supported (AF_INET) sa: sa_set_port: no af 0 (port 33340) udp: listen: getaddrinfo: ?:0 (Name or service not known) ... stream: rtp_listen failed: af=AF_UNSPEC ports=1024-49152 (Cannot assign requested address) stream: failed to create socket for media 'audio' (Cannot assign requested address) ua: call_alloc: Cannot assign requested address ```
1 parent 923d624 commit 287766f

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

src/ua.c

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,8 @@ int ua_call_alloc(struct call **callp, struct ua *ua,
484484
{
485485
const struct network *net = baresip_network();
486486
struct call_prm cprm;
487-
int af = AF_UNSPEC;
488-
int af_sdp = AF_UNSPEC;
487+
int af;
488+
int af_sdp;
489489
int err;
490490

491491
if (!callp || !ua)
@@ -494,17 +494,7 @@ int ua_call_alloc(struct call **callp, struct ua *ua,
494494
if (msg && (af_sdp = sdp_af_hint(msg->mb))) {
495495
info("ua: using AF from sdp offer: af=%s\n",
496496
net_af2name(af_sdp));
497-
if (!net_af_enabled(net, af_sdp)) {
498-
warning("ua: SDP offer AF not supported (%s)\n",
499-
net_af2name(af_sdp));
500-
}
501-
else if (!sa_isset(net_laddr_af(net, af_sdp), SA_ADDR)) {
502-
warning("ua: SDP offer AF not available (%s)\n",
503-
net_af2name(af_sdp));
504-
}
505-
else {
506-
af = af_sdp;
507-
}
497+
af = af_sdp;
508498
}
509499
else if (ua->af_media &&
510500
sa_isset(net_laddr_af(net, ua->af_media), SA_ADDR)) {
@@ -1356,7 +1346,9 @@ static bool require_handler(const struct sip_hdr *hdr,
13561346
static void sipsess_conn_handler(const struct sip_msg *msg, void *arg)
13571347
{
13581348
struct config *config = conf_config();
1349+
const struct network *net = baresip_network();
13591350
const struct sip_hdr *hdr;
1351+
int af_sdp;
13601352
struct ua *ua;
13611353
struct call *call = NULL;
13621354
char to_uri[256];
@@ -1402,6 +1394,25 @@ static void sipsess_conn_handler(const struct sip_msg *msg, void *arg)
14021394
return;
14031395
}
14041396

1397+
/* Check if offered media AF is supported and available */
1398+
af_sdp = sdp_af_hint(msg->mb);
1399+
if (af_sdp) {
1400+
if (!net_af_enabled(net, af_sdp)) {
1401+
warning("ua: SDP offer AF not supported (%s)\n",
1402+
net_af2name(af_sdp));
1403+
af_sdp = 0;
1404+
} else if (!sa_isset(net_laddr_af(net, af_sdp), SA_ADDR)) {
1405+
warning("ua: SDP offer AF not available (%s)\n",
1406+
net_af2name(af_sdp));
1407+
af_sdp = 0;
1408+
}
1409+
if (!af_sdp) {
1410+
(void)sip_treply(NULL, uag_sip(), msg, 488,
1411+
"Not Acceptable Here");
1412+
return;
1413+
}
1414+
}
1415+
14051416
(void)pl_strcpy(&msg->to.auri, to_uri, sizeof(to_uri));
14061417

14071418
err = ua_call_alloc(&call, ua, VIDMODE_ON, msg, NULL, to_uri, true);

0 commit comments

Comments
 (0)