* sockaddr_dl::sdl_e_type is now always stored in network order.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39777 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-12-08 23:42:34 +00:00
parent 2cae3e8847
commit 54490bbd50
3 changed files with 19 additions and 19 deletions
@@ -208,7 +208,7 @@ ipv4_to_ether_multicast(sockaddr_dl *destination, const sockaddr_in *source)
destination->sdl_family = AF_LINK; destination->sdl_family = AF_LINK;
destination->sdl_index = 0; destination->sdl_index = 0;
destination->sdl_type = IFT_ETHER; 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_nlen = destination->sdl_slen = 0;
destination->sdl_alen = ETHER_ADDRESS_LENGTH; destination->sdl_alen = ETHER_ADDRESS_LENGTH;
@@ -285,7 +285,7 @@ arp_entry::Add(in_addr_t protocolAddress, sockaddr_dl *hardwareAddress,
if (hardwareAddress != NULL) { if (hardwareAddress != NULL) {
// this entry is already resolved // this entry is already resolved
entry->hardware_address = *hardwareAddress; entry->hardware_address = *hardwareAddress;
entry->hardware_address.sdl_e_type = ETHER_TYPE_IP; entry->hardware_address.sdl_e_type = htons(ETHER_TYPE_IP);
} else { } else {
// this entry still needs to be resolved // this entry still needs to be resolved
entry->hardware_address.sdl_alen = 0; entry->hardware_address.sdl_alen = 0;
@@ -459,7 +459,7 @@ arp_set_local_entry(arp_protocol* protocol, const sockaddr* local)
address.sdl_len = sizeof(sockaddr_dl); address.sdl_len = sizeof(sockaddr_dl);
address.sdl_family = AF_LINK; address.sdl_family = AF_LINK;
address.sdl_type = IFT_ETHER; 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_nlen = 0;
address.sdl_slen = 0; address.sdl_slen = 0;
address.sdl_alen = interface->device->address.length; address.sdl_alen = interface->device->address.length;
@@ -823,7 +823,7 @@ arp_start_resolve(arp_protocol* protocol, in_addr_t address, arp_entry** _entry)
source.sdl_family = AF_LINK; source.sdl_family = AF_LINK;
source.sdl_index = device->index; source.sdl_index = device->index;
source.sdl_type = IFT_ETHER; 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_nlen = source.sdl_slen = 0;
source.sdl_alen = ETHER_ADDRESS_LENGTH; source.sdl_alen = ETHER_ADDRESS_LENGTH;
memcpy(source.sdl_data, device->address.data, ETHER_ADDRESS_LENGTH); memcpy(source.sdl_data, device->address.data, ETHER_ADDRESS_LENGTH);
@@ -862,7 +862,7 @@ arp_control(const char *subsystem, uint32 function, void *buffer,
hardwareAddress.sdl_family = AF_LINK; hardwareAddress.sdl_family = AF_LINK;
hardwareAddress.sdl_index = 0; hardwareAddress.sdl_index = 0;
hardwareAddress.sdl_type = IFT_ETHER; 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_nlen = hardwareAddress.sdl_slen = 0;
hardwareAddress.sdl_alen = ETHER_ADDRESS_LENGTH; hardwareAddress.sdl_alen = ETHER_ADDRESS_LENGTH;
memcpy(hardwareAddress.sdl_data, control.ethernet_address, memcpy(hardwareAddress.sdl_data, control.ethernet_address,
@@ -52,7 +52,7 @@ ethernet_deframe(net_device* device, net_buffer* buffer)
source.sdl_family = AF_LINK; source.sdl_family = AF_LINK;
source.sdl_index = device->index; source.sdl_index = device->index;
source.sdl_type = IFT_ETHER; 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_nlen = source.sdl_slen = 0;
source.sdl_alen = ETHER_ADDRESS_LENGTH; source.sdl_alen = ETHER_ADDRESS_LENGTH;
memcpy(source.sdl_data, header.source, ETHER_ADDRESS_LENGTH); memcpy(source.sdl_data, header.source, ETHER_ADDRESS_LENGTH);
@@ -61,7 +61,7 @@ ethernet_deframe(net_device* device, net_buffer* buffer)
destination.sdl_family = AF_LINK; destination.sdl_family = AF_LINK;
destination.sdl_index = device->index; destination.sdl_index = device->index;
destination.sdl_type = IFT_ETHER; 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_nlen = destination.sdl_slen = 0;
destination.sdl_alen = ETHER_ADDRESS_LENGTH; destination.sdl_alen = ETHER_ADDRESS_LENGTH;
memcpy(destination.sdl_data, header.destination, ETHER_ADDRESS_LENGTH); memcpy(destination.sdl_data, header.destination, ETHER_ADDRESS_LENGTH);
@@ -152,7 +152,7 @@ ethernet_frame_send_data(net_datalink_protocol* protocol, net_buffer* buffer)
ether_header &header = bufferHeader.Data(); 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); memcpy(header.source, LLADDR(&source), ETHER_ADDRESS_LENGTH);
if ((buffer->flags & MSG_BCAST) != 0) if ((buffer->flags & MSG_BCAST) != 0)
memcpy(header.destination, kBroadcastAddress, ETHER_ADDRESS_LENGTH); memcpy(header.destination, kBroadcastAddress, ETHER_ADDRESS_LENGTH);
@@ -161,7 +161,7 @@ ipv6_to_ether_multicast(sockaddr_dl* destination, const sockaddr_in6* source)
destination->sdl_family = AF_LINK; destination->sdl_family = AF_LINK;
destination->sdl_index = 0; destination->sdl_index = 0;
destination->sdl_type = IFT_ETHER; 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_nlen = destination->sdl_slen = 0;
destination->sdl_alen = ETHER_ADDRESS_LENGTH; destination->sdl_alen = ETHER_ADDRESS_LENGTH;
@@ -284,14 +284,14 @@ ndp_entry::Hash(void* _entry, const void* _key, uint32 range)
} }
ndp_entry* ndp_entry*
ndp_entry::Lookup(const in6_addr& address) ndp_entry::Lookup(const in6_addr& address)
{ {
return (ndp_entry*)hash_lookup(sCache, &address); return (ndp_entry*)hash_lookup(sCache, &address);
} }
ndp_entry* ndp_entry*
ndp_entry::Add(const in6_addr& protocolAddress, sockaddr_dl* hardwareAddress, ndp_entry::Add(const in6_addr& protocolAddress, sockaddr_dl* hardwareAddress,
uint32 flags) uint32 flags)
{ {
@@ -312,7 +312,7 @@ ndp_entry::Add(const in6_addr& protocolAddress, sockaddr_dl* hardwareAddress,
if (hardwareAddress != NULL) { if (hardwareAddress != NULL) {
// this entry is already resolved // this entry is already resolved
entry->hardware_address = *hardwareAddress; entry->hardware_address = *hardwareAddress;
entry->hardware_address.sdl_e_type = ETHER_TYPE_IPV6; entry->hardware_address.sdl_e_type = htons(ETHER_TYPE_IPV6);
} else { } else {
// this entry still needs to be resolved // this entry still needs to be resolved
entry->hardware_address.sdl_alen = 0; entry->hardware_address.sdl_alen = 0;
@@ -614,7 +614,7 @@ ndp_set_local_entry(ipv6_datalink_protocol* protocol, const sockaddr* local)
address.sdl_len = sizeof(sockaddr_dl); address.sdl_len = sizeof(sockaddr_dl);
address.sdl_family = AF_LINK; address.sdl_family = AF_LINK;
address.sdl_type = IFT_ETHER; 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_nlen = 0;
address.sdl_slen = 0; address.sdl_slen = 0;
address.sdl_alen = interface->device->address.length; address.sdl_alen = interface->device->address.length;
@@ -685,7 +685,7 @@ ndp_receive_solicitation(net_buffer* buffer, bool* reuseBuffer)
hardwareAddress.sdl_family = AF_LINK; hardwareAddress.sdl_family = AF_LINK;
hardwareAddress.sdl_index = 0; hardwareAddress.sdl_index = 0;
hardwareAddress.sdl_type = IFT_ETHER; 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_nlen = hardwareAddress.sdl_slen = 0;
hardwareAddress.sdl_alen = ETHER_ADDRESS_LENGTH; hardwareAddress.sdl_alen = ETHER_ADDRESS_LENGTH;
memcpy(LLADDR(&hardwareAddress), header.link_address, memcpy(LLADDR(&hardwareAddress), header.link_address,
@@ -760,7 +760,7 @@ ndp_receive_advertisement(net_buffer* buffer)
hardwareAddress.sdl_family = AF_LINK; hardwareAddress.sdl_family = AF_LINK;
hardwareAddress.sdl_index = 0; hardwareAddress.sdl_index = 0;
hardwareAddress.sdl_type = IFT_ETHER; 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_nlen = hardwareAddress.sdl_slen = 0;
hardwareAddress.sdl_alen = ETHER_ADDRESS_LENGTH; hardwareAddress.sdl_alen = ETHER_ADDRESS_LENGTH;
memcpy(LLADDR(&hardwareAddress), header.link_address, ETHER_ADDRESS_LENGTH); memcpy(LLADDR(&hardwareAddress), header.link_address, ETHER_ADDRESS_LENGTH);
@@ -1049,7 +1049,7 @@ ipv6_datalink_send_data(net_datalink_protocol* _protocol, net_buffer* buffer)
if (status < B_OK) if (status < B_OK)
return status; return status;
} }
if ((entry->flags & NDP_FLAG_REJECT) != 0) if ((entry->flags & NDP_FLAG_REJECT) != 0)
return EHOSTUNREACH; return EHOSTUNREACH;
if (!(entry->flags & NDP_FLAG_VALID)) { if (!(entry->flags & NDP_FLAG_VALID)) {
@@ -1112,7 +1112,7 @@ ipv6_datalink_change_address(net_datalink_protocol* _protocol,
// Those are the options we handle // Those are the options we handle
if ((protocol->interface->flags & IFF_UP) != 0) { if ((protocol->interface->flags & IFF_UP) != 0) {
// Update NDP entry for the local address // Update NDP entry for the local address
if (newAddress != NULL && newAddress->sa_family == AF_INET6) { if (newAddress != NULL && newAddress->sa_family == AF_INET6) {
status_t status = ndp_set_local_entry(protocol, newAddress); status_t status = ndp_set_local_entry(protocol, newAddress);
if (status != B_OK) if (status != B_OK)
@@ -1144,13 +1144,13 @@ ipv6_datalink_change_address(net_datalink_protocol* _protocol,
socketAddress.sin6_addr.s6_addr[0] = 0xff; socketAddress.sin6_addr.s6_addr[0] = 0xff;
net_route route; net_route route;
memset(&route, 0, sizeof(net_route)); memset(&route, 0, sizeof(net_route));
route.destination = (sockaddr*)&socketAddress; route.destination = (sockaddr*)&socketAddress;
route.mask = (sockaddr*)&socketAddress; route.mask = (sockaddr*)&socketAddress;
route.flags = 0; route.flags = 0;
sDatalinkModule->remove_route(address->domain, &route); sDatalinkModule->remove_route(address->domain, &route);
} }
} }
break; break;
default: default: