[haiku-commits] r39777 - in haiku/trunk/src/add-ons/kernel/network/datalink_protocols: arp ethernet_frame ipv6_datagram

Author: axeld
Date: 2010-12-09 00:42:34 +0100 (Thu, 09 Dec 2010)
New Revision: 39777
Changeset: http://dev.haiku-os.org/changeset/39777

Modified:
   haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp
   
haiku/trunk/src/add-ons/kernel/network/datalink_protocols/ethernet_frame/ethernet_frame.cpp
   
haiku/trunk/src/add-ons/kernel/network/datalink_protocols/ipv6_datagram/ipv6_datagram.cpp
Log:
* sockaddr_dl::sdl_e_type is now always stored in network order.


Modified: haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp       
2010-12-08 23:35:45 UTC (rev 39776)
+++ haiku/trunk/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp       
2010-12-08 23:42:34 UTC (rev 39777)
@@ -208,7 +208,7 @@
        destination->sdl_family = AF_LINK;
        destination->sdl_index = 0;
        destination->sdl_type = IFT_ETHER;
-       destination->sdl_e_type = ETHER_TYPE_IP;
+       destination->sdl_e_type = htons(ETHER_TYPE_IP);
        destination->sdl_nlen = destination->sdl_slen = 0;
        destination->sdl_alen = ETHER_ADDRESS_LENGTH;
 
@@ -285,7 +285,7 @@
        if (hardwareAddress != NULL) {
                // this entry is already resolved
                entry->hardware_address = *hardwareAddress;
-               entry->hardware_address.sdl_e_type = ETHER_TYPE_IP;
+               entry->hardware_address.sdl_e_type = htons(ETHER_TYPE_IP);
        } else {
                // this entry still needs to be resolved
                entry->hardware_address.sdl_alen = 0;
@@ -459,7 +459,7 @@
        address.sdl_len = sizeof(sockaddr_dl);
        address.sdl_family = AF_LINK;
        address.sdl_type = IFT_ETHER;
-       address.sdl_e_type = ETHER_TYPE_IP;
+       address.sdl_e_type = htons(ETHER_TYPE_IP);
        address.sdl_nlen = 0;
        address.sdl_slen = 0;
        address.sdl_alen = interface->device->address.length;
@@ -823,7 +823,7 @@
        source.sdl_family = AF_LINK;
        source.sdl_index = device->index;
        source.sdl_type = IFT_ETHER;
-       source.sdl_e_type = ETHER_TYPE_ARP;
+       source.sdl_e_type = htons(ETHER_TYPE_ARP);
        source.sdl_nlen = source.sdl_slen = 0;
        source.sdl_alen = ETHER_ADDRESS_LENGTH;
        memcpy(source.sdl_data, device->address.data, ETHER_ADDRESS_LENGTH);
@@ -862,7 +862,7 @@
                        hardwareAddress.sdl_family = AF_LINK;
                        hardwareAddress.sdl_index = 0;
                        hardwareAddress.sdl_type = IFT_ETHER;
-                       hardwareAddress.sdl_e_type = ETHER_TYPE_IP;
+                       hardwareAddress.sdl_e_type = htons(ETHER_TYPE_IP);
                        hardwareAddress.sdl_nlen = hardwareAddress.sdl_slen = 0;
                        hardwareAddress.sdl_alen = ETHER_ADDRESS_LENGTH;
                        memcpy(hardwareAddress.sdl_data, 
control.ethernet_address,

Modified: 
haiku/trunk/src/add-ons/kernel/network/datalink_protocols/ethernet_frame/ethernet_frame.cpp
===================================================================
--- 
haiku/trunk/src/add-ons/kernel/network/datalink_protocols/ethernet_frame/ethernet_frame.cpp
 2010-12-08 23:35:45 UTC (rev 39776)
+++ 
haiku/trunk/src/add-ons/kernel/network/datalink_protocols/ethernet_frame/ethernet_frame.cpp
 2010-12-08 23:42:34 UTC (rev 39777)
@@ -52,7 +52,7 @@
        source.sdl_family = AF_LINK;
        source.sdl_index = device->index;
        source.sdl_type = IFT_ETHER;
-       source.sdl_e_type = type;
+       source.sdl_e_type = header.type;
        source.sdl_nlen = source.sdl_slen = 0;
        source.sdl_alen = ETHER_ADDRESS_LENGTH;
        memcpy(source.sdl_data, header.source, ETHER_ADDRESS_LENGTH);
@@ -61,7 +61,7 @@
        destination.sdl_family = AF_LINK;
        destination.sdl_index = device->index;
        destination.sdl_type = IFT_ETHER;
-       destination.sdl_e_type = type;
+       destination.sdl_e_type = header.type;
        destination.sdl_nlen = destination.sdl_slen = 0;
        destination.sdl_alen = ETHER_ADDRESS_LENGTH;
        memcpy(destination.sdl_data, header.destination, ETHER_ADDRESS_LENGTH);
@@ -152,7 +152,7 @@
 
        ether_header &header = bufferHeader.Data();
 
-       header.type = htons(source.sdl_e_type);
+       header.type = source.sdl_e_type;
        memcpy(header.source, LLADDR(&source), ETHER_ADDRESS_LENGTH);
        if ((buffer->flags & MSG_BCAST) != 0)
                memcpy(header.destination, kBroadcastAddress, 
ETHER_ADDRESS_LENGTH);

Modified: 
haiku/trunk/src/add-ons/kernel/network/datalink_protocols/ipv6_datagram/ipv6_datagram.cpp
===================================================================
--- 
haiku/trunk/src/add-ons/kernel/network/datalink_protocols/ipv6_datagram/ipv6_datagram.cpp
   2010-12-08 23:35:45 UTC (rev 39776)
+++ 
haiku/trunk/src/add-ons/kernel/network/datalink_protocols/ipv6_datagram/ipv6_datagram.cpp
   2010-12-08 23:42:34 UTC (rev 39777)
@@ -161,7 +161,7 @@
        destination->sdl_family = AF_LINK;
        destination->sdl_index = 0;
        destination->sdl_type = IFT_ETHER;
-       destination->sdl_e_type = ETHER_TYPE_IPV6;
+       destination->sdl_e_type = htons(ETHER_TYPE_IPV6);
        destination->sdl_nlen = destination->sdl_slen = 0;
        destination->sdl_alen = ETHER_ADDRESS_LENGTH;
 
@@ -284,14 +284,14 @@
 }
 
 
-ndp_entry* 
+ndp_entry*
 ndp_entry::Lookup(const in6_addr& address)
 {
        return (ndp_entry*)hash_lookup(sCache, &address);
 }
 
 
-ndp_entry* 
+ndp_entry*
 ndp_entry::Add(const in6_addr& protocolAddress, sockaddr_dl* hardwareAddress,
        uint32 flags)
 {
@@ -312,7 +312,7 @@
        if (hardwareAddress != NULL) {
                // this entry is already resolved
                entry->hardware_address = *hardwareAddress;
-               entry->hardware_address.sdl_e_type = ETHER_TYPE_IPV6;
+               entry->hardware_address.sdl_e_type = htons(ETHER_TYPE_IPV6);
        } else {
                // this entry still needs to be resolved
                entry->hardware_address.sdl_alen = 0;
@@ -614,7 +614,7 @@
        address.sdl_len = sizeof(sockaddr_dl);
        address.sdl_family = AF_LINK;
        address.sdl_type = IFT_ETHER;
-       address.sdl_e_type = ETHER_TYPE_IPV6;
+       address.sdl_e_type = htons(ETHER_TYPE_IPV6);
        address.sdl_nlen = 0;
        address.sdl_slen = 0;
        address.sdl_alen = interface->device->address.length;
@@ -685,7 +685,7 @@
                hardwareAddress.sdl_family = AF_LINK;
                hardwareAddress.sdl_index = 0;
                hardwareAddress.sdl_type = IFT_ETHER;
-               hardwareAddress.sdl_e_type = ETHER_TYPE_IPV6;
+               hardwareAddress.sdl_e_type = htons(ETHER_TYPE_IPV6);
                hardwareAddress.sdl_nlen = hardwareAddress.sdl_slen = 0;
                hardwareAddress.sdl_alen = ETHER_ADDRESS_LENGTH;
                memcpy(LLADDR(&hardwareAddress), header.link_address,
@@ -760,7 +760,7 @@
        hardwareAddress.sdl_family = AF_LINK;
        hardwareAddress.sdl_index = 0;
        hardwareAddress.sdl_type = IFT_ETHER;
-       hardwareAddress.sdl_e_type = ETHER_TYPE_IPV6;
+       hardwareAddress.sdl_e_type = htons(ETHER_TYPE_IPV6);
        hardwareAddress.sdl_nlen = hardwareAddress.sdl_slen = 0;
        hardwareAddress.sdl_alen = ETHER_ADDRESS_LENGTH;
        memcpy(LLADDR(&hardwareAddress), header.link_address, 
ETHER_ADDRESS_LENGTH);
@@ -1049,7 +1049,7 @@
                        if (status < B_OK)
                                return status;
                }
-                       
+
                if ((entry->flags & NDP_FLAG_REJECT) != 0)
                        return EHOSTUNREACH;
                if (!(entry->flags & NDP_FLAG_VALID)) {
@@ -1112,7 +1112,7 @@
                        // Those are the options we handle
                        if ((protocol->interface->flags & IFF_UP) != 0) {
                                // Update NDP entry for the local address
-                       
+
                                if (newAddress != NULL && newAddress->sa_family 
== AF_INET6) {
                                        status_t status = 
ndp_set_local_entry(protocol, newAddress);
                                        if (status != B_OK)
@@ -1144,13 +1144,13 @@
                                        socketAddress.sin6_addr.s6_addr[0] = 
0xff;
 
                                        net_route route;
-                                       memset(&route, 0, sizeof(net_route));   
                
+                                       memset(&route, 0, sizeof(net_route));
                                        route.destination = 
(sockaddr*)&socketAddress;
                                        route.mask = (sockaddr*)&socketAddress;
                                        route.flags = 0;
                                        
sDatalinkModule->remove_route(address->domain, &route);
                                }
-                       }                       
+                       }
                        break;
 
                default:


Other related posts:

  • » [haiku-commits] r39777 - in haiku/trunk/src/add-ons/kernel/network/datalink_protocols: arp ethernet_frame ipv6_datagram - axeld