aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-01-05 23:43:34 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-01-05 23:43:34 +0000
commit887f92b7bb58ff8898c02e1966eeb6f98e34eb45 (patch)
tree10ca5b8f8cf5208d778a72fc319cb4fe7e1da120
parent66676fbd268a73c9d3d66b536cb102bdca569d1e (diff)
If pedantic mode enabled, look for media-level addresses
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4688 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xchannels/chan_sip.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 61f25dbe0..fa0f63214 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2629,6 +2629,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
struct hostent *hp;
struct ast_hostent ahp;
int codec;
+ int destiterator = 0;
int iterator;
int sendonly = 0;
int x,y;
@@ -2643,7 +2644,8 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
return -1;
}
m = get_sdp(req, "m");
- c = get_sdp(req, "c");
+ sdpLineNum_iterator_init(&destiterator);
+ c = get_sdp_iterate(&destiterator, req, "c");
if (ast_strlen_zero(m) || ast_strlen_zero(c)) {
ast_log(LOG_WARNING, "Insufficient information for SDP (m = '%s', c = '%s')\n", m, c);
return -1;
@@ -2702,7 +2704,21 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
}
}
}
-
+ /* Check for Media-description-level-address for audio */
+ if (pedanticsipchecking) {
+ c = get_sdp_iterate(&destiterator, req, "c");
+ if (!ast_strlen_zero(c)) {
+ if (sscanf(c, "IN IP4 %256s", host) != 1) {
+ ast_log(LOG_WARNING, "Invalid secondary host in c= line, '%s'\n", c);
+ } else {
+ /* XXX This could block for a long time, and block the main thread! XXX */
+ hp = ast_gethostbyname(host, &ahp);
+ if (!hp) {
+ ast_log(LOG_WARNING, "Unable to lookup host in secondary c= line, '%s'\n", c);
+ }
+ }
+ }
+ }
/* RTP addresses and ports for audio and video */
sin.sin_family = AF_INET;
memcpy(&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr));
@@ -2716,6 +2732,21 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
ast_log(LOG_DEBUG,"Peer audio RTP is at port %s:%d\n",ast_inet_ntoa(iabuf, sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
}
}
+ /* Check for Media-description-level-address for video */
+ if (pedanticsipchecking) {
+ c = get_sdp_iterate(&destiterator, req, "c");
+ if (!ast_strlen_zero(c)) {
+ if (sscanf(c, "IN IP4 %256s", host) != 1) {
+ ast_log(LOG_WARNING, "Invalid secondary host in c= line, '%s'\n", c);
+ } else {
+ /* XXX This could block for a long time, and block the main thread! XXX */
+ hp = ast_gethostbyname(host, &ahp);
+ if (!hp) {
+ ast_log(LOG_WARNING, "Unable to lookup host in secondary c= line, '%s'\n", c);
+ }
+ }
+ }
+ }
/* Setup video port number */
sin.sin_port = htons(vportno);
if (p->vrtp && sin.sin_port) {