ipaccess-find: don't try to parse packets that are not IPAC_MSGT_ID_RESP

This commit is contained in:
Harald Welte 2009-08-08 12:14:53 +02:00
parent e26d079c97
commit 81cff3c8c5
1 changed files with 13 additions and 0 deletions

View File

@ -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);
}