diff options
author | Michael Brown <mcb30@ipxe.org> | 2015-07-21 15:26:52 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2015-07-28 13:48:29 +0100 |
commit | 6efcabd4151538781053716bec1c7eccd759df26 (patch) | |
tree | 44d56878eb316b864d172d228c80aa1bf3596e40 /src/net | |
parent | 9c185e2eac39561c2e9847c355c5b710c3e557b5 (diff) | |
download | ipxe-6efcabd4151538781053716bec1c7eccd759df26.zip ipxe-6efcabd4151538781053716bec1c7eccd759df26.tar.gz ipxe-6efcabd4151538781053716bec1c7eccd759df26.tar.bz2 |
[ipv4] Redefine IP address constants to avoid unnecessary byte swapping
Redefine various IPv4 address constants and testing macros to avoid
unnecessary byte swapping at runtime, and slightly rename the macros
to prevent code from accidentally using the old definitions.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ipv4.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/net/ipv4.c b/src/net/ipv4.c index ed22c4d..3552cc4 100644 --- a/src/net/ipv4.c +++ b/src/net/ipv4.c @@ -314,7 +314,7 @@ static int ipv4_tx ( struct io_buffer *iobuf, if ( sin_src ) iphdr->src = sin_src->sin_addr; if ( ( next_hop.s_addr != INADDR_BROADCAST ) && - ( ! IN_MULTICAST ( ntohl ( next_hop.s_addr ) ) ) && + ( ! IN_IS_MULTICAST ( next_hop.s_addr ) ) && ( ( miniroute = ipv4_route ( &next_hop ) ) != NULL ) ) { iphdr->src = miniroute->address; netmask = miniroute->netmask; @@ -353,7 +353,7 @@ static int ipv4_tx ( struct io_buffer *iobuf, /* Broadcast address */ ipv4_stats.out_bcast_pkts++; ll_dest = netdev->ll_broadcast; - } else if ( IN_MULTICAST ( ntohl ( next_hop.s_addr ) ) ) { + } else if ( IN_IS_MULTICAST ( next_hop.s_addr ) ) { /* Multicast address */ ipv4_stats.out_mcast_pkts++; if ( ( rc = netdev->ll_protocol->mc_hash ( AF_INET, &next_hop, @@ -816,12 +816,12 @@ static int ipv4_create_routes ( void ) { fetch_ipv4_setting ( settings, &netmask_setting, &netmask ); /* Calculate default netmask, if necessary */ if ( ! netmask.s_addr ) { - if ( IN_CLASSA ( ntohl ( address.s_addr ) ) ) { - netmask.s_addr = htonl ( IN_CLASSA_NET ); - } else if ( IN_CLASSB ( ntohl ( address.s_addr ) ) ) { - netmask.s_addr = htonl ( IN_CLASSB_NET ); - } else if ( IN_CLASSC ( ntohl ( address.s_addr ) ) ) { - netmask.s_addr = htonl ( IN_CLASSC_NET ); + if ( IN_IS_CLASSA ( address.s_addr ) ) { + netmask.s_addr = INADDR_NET_CLASSA; + } else if ( IN_IS_CLASSB ( address.s_addr ) ) { + netmask.s_addr = INADDR_NET_CLASSB; + } else if ( IN_IS_CLASSC ( address.s_addr ) ) { + netmask.s_addr = INADDR_NET_CLASSC; } } /* Get default gateway, if present */ |