From ba61b249609d28a2a3e750b3602d1ba2a8d8b140 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 28 Nov 2017 08:48:12 +0100 Subject: net: Add and use IP_BROADCAST Rather than using the hardcoded value 0xffffffff in several places add a define for the broadcast IP. Signed-off-by: Sascha Hauer --- net/dhcp.c | 2 +- net/net.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'net') diff --git a/net/dhcp.c b/net/dhcp.c index c5386fe942..4d74733d37 100644 --- a/net/dhcp.c +++ b/net/dhcp.c @@ -661,7 +661,7 @@ int dhcp(int retries, struct dhcp_req_param *param) if (!retries) retries = DHCP_DEFAULT_RETRY; - dhcp_con = net_udp_new(0xffffffff, PORT_BOOTPS, dhcp_handler, NULL); + dhcp_con = net_udp_new(IP_BROADCAST, PORT_BOOTPS, dhcp_handler, NULL); if (IS_ERR(dhcp_con)) { ret = PTR_ERR(dhcp_con); goto out; diff --git a/net/net.c b/net/net.c index 12e63c664e..205543a425 100644 --- a/net/net.c +++ b/net/net.c @@ -276,7 +276,7 @@ static struct net_connection *net_new(IPaddr_t dest, rx_handler_f *handler, } /* If we don't have an ip only broadcast is allowed */ - if (!edev->ipaddr && dest != 0xffffffff) + if (!edev->ipaddr && dest != IP_BROADCAST) return ERR_PTR(-ENETDOWN); con = xzalloc(sizeof(*con)); @@ -291,7 +291,7 @@ static struct net_connection *net_new(IPaddr_t dest, rx_handler_f *handler, con->icmp = (struct icmphdr *)(con->packet + ETHER_HDR_SIZE + sizeof(struct iphdr)); con->handler = handler; - if (dest == 0xffffffff) { + if (dest == IP_BROADCAST) { memset(con->et->et_dest, 0xff, 6); } else { ret = arp_request(dest, con->et->et_dest); @@ -525,7 +525,7 @@ static int net_handle_ip(struct eth_device *edev, unsigned char *pkt, int len) goto bad; tmp = net_read_ip(&ip->daddr); - if (edev->ipaddr && tmp != edev->ipaddr && tmp != 0xffffffff) + if (edev->ipaddr && tmp != edev->ipaddr && tmp != IP_BROADCAST) return 0; switch (ip->protocol) { -- cgit v1.2.3