Skip to content

Commit

Permalink
ua: check offerred media AF already at sipsess_conn_handler()
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
juha-h committed Feb 1, 2020
1 parent 923d624 commit 287766f
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions src/ua.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ int ua_call_alloc(struct call **callp, struct ua *ua,
{
const struct network *net = baresip_network();
struct call_prm cprm;
int af = AF_UNSPEC;
int af_sdp = AF_UNSPEC;
int af;
int af_sdp;
int err;

if (!callp || !ua)
Expand All @@ -494,17 +494,7 @@ int ua_call_alloc(struct call **callp, struct ua *ua,
if (msg && (af_sdp = sdp_af_hint(msg->mb))) {
info("ua: using AF from sdp offer: af=%s\n",
net_af2name(af_sdp));
if (!net_af_enabled(net, af_sdp)) {
warning("ua: SDP offer AF not supported (%s)\n",
net_af2name(af_sdp));
}
else if (!sa_isset(net_laddr_af(net, af_sdp), SA_ADDR)) {
warning("ua: SDP offer AF not available (%s)\n",
net_af2name(af_sdp));
}
else {
af = af_sdp;
}
af = af_sdp;
}
else if (ua->af_media &&
sa_isset(net_laddr_af(net, ua->af_media), SA_ADDR)) {
Expand Down Expand Up @@ -1356,7 +1346,9 @@ static bool require_handler(const struct sip_hdr *hdr,
static void sipsess_conn_handler(const struct sip_msg *msg, void *arg)
{
struct config *config = conf_config();
const struct network *net = baresip_network();
const struct sip_hdr *hdr;
int af_sdp;
struct ua *ua;
struct call *call = NULL;
char to_uri[256];
Expand Down Expand Up @@ -1402,6 +1394,25 @@ static void sipsess_conn_handler(const struct sip_msg *msg, void *arg)
return;
}

/* Check if offered media AF is supported and available */
af_sdp = sdp_af_hint(msg->mb);
if (af_sdp) {
if (!net_af_enabled(net, af_sdp)) {
warning("ua: SDP offer AF not supported (%s)\n",
net_af2name(af_sdp));
af_sdp = 0;
} else if (!sa_isset(net_laddr_af(net, af_sdp), SA_ADDR)) {
warning("ua: SDP offer AF not available (%s)\n",
net_af2name(af_sdp));
af_sdp = 0;
}
if (!af_sdp) {
(void)sip_treply(NULL, uag_sip(), msg, 488,
"Not Acceptable Here");
return;
}
}

(void)pl_strcpy(&msg->to.auri, to_uri, sizeof(to_uri));

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

0 comments on commit 287766f

Please sign in to comment.