Commit ebf0aa97 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

Merge branch 'adam-check_ip' into proposed_master

parents 69f53c93 31552ac8
......@@ -205,3 +205,11 @@ void setIP(unsigned char *IP)
ip_status = IP_TRAINING;
bootp_retry = 0;
}
/* Check the destination IP of the incoming packet */
int check_dest_ip(unsigned char *buf)
{
if (!buf)
return -1;
return memcmp(buf + IP_DEST, myIP, 4);
}
......@@ -61,6 +61,7 @@ struct wr_udp_addr {
};
void fill_udp(uint8_t * buf, int len, struct wr_udp_addr *uaddr);
int check_dest_ip(unsigned char *buf);
void syslog_init(void);
int syslog_poll(void);
......
......@@ -1403,6 +1403,14 @@ static int snmp_poll(void)
if (len <= UDP_END + sizeof(match_array))
return 0;
/* Check the destination IP of SNMP packets. IP version, protocol and
* port are checked in the function update_rx_queues, so no need to
* check it again */
if (check_dest_ip(buf)) {
snmp_verbose("wrong destination IP\n");
return 0;
}
len = snmp_respond(buf + UDP_END);
if (len < 0)
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment