aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/ipaccess-find.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2009-08-08 12:14:53 +0200
committerHarald Welte <laforge@gnumonks.org>2009-08-08 12:14:53 +0200
commit81cff3c8c5bd4cd2845b125de791c9363b4b4594 (patch)
tree5c715c8ae79a6d3491ec582347b70a020838f2ee /openbsc/src/ipaccess-find.c
parente26d079c978497622ad1fd0c285e4ac59c66a48e (diff)
ipaccess-find: don't try to parse packets that are not IPAC_MSGT_ID_RESP
Diffstat (limited to 'openbsc/src/ipaccess-find.c')
-rw-r--r--openbsc/src/ipaccess-find.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/openbsc/src/ipaccess-find.c b/openbsc/src/ipaccess-find.c
index e495a4fa6..f469b6788 100644
--- a/openbsc/src/ipaccess-find.c
+++ b/openbsc/src/ipaccess-find.c
@@ -62,6 +62,12 @@ static int udp_sock(const char *ifname)
goto err;
#if 0
+ /* we cannot bind, since the response packets don't come from
+ * the broadcast address */
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(3006);
+ inet_aton("255.255.255.255", &sa.sin_addr);
+
rc = connect(fd, (struct sockaddr *)&sa, sizeof(sa));
if (rc < 0)
goto err;
@@ -127,6 +133,13 @@ static int read_response(int fd)
if (len < 0)
return len;
+ /* 2 bytes length, 1 byte protocol (0xfe) */
+ if (buf[2] != 0xfe)
+ return 0;
+
+ if (buf[4] != IPAC_MSGT_ID_RESP)
+ return 0;
+
return parse_response(buf+6, len-6);
}