os: rename 'bswap' to 'host_to_big_endian'

This commit is contained in:
Sebastian Sumpf 2015-04-29 11:36:54 +02:00 committed by Christian Helmuth
parent 6a89bd15fd
commit 33bc63e7c3
7 changed files with 28 additions and 28 deletions

View File

@ -63,8 +63,8 @@ class Storage_device : public Genode::List<Storage_device>::Element,
wait_for_completion(&comp); wait_for_completion(&comp);
Genode::uint32_t *data = (Genode::uint32_t *)scsi_buffer_data(cmnd); Genode::uint32_t *data = (Genode::uint32_t *)scsi_buffer_data(cmnd);
_block_count = bswap(data[0]); _block_count = host_to_big_endian(data[0]);
_block_size = bswap(data[1]); _block_size = host_to_big_endian(data[1]);
/* if device returns the highest block number */ /* if device returns the highest block number */
if (!_sdev->fix_capacity) if (!_sdev->fix_capacity)
@ -100,11 +100,11 @@ class Storage_device : public Genode::List<Storage_device>::Element,
*p = packet; *p = packet;
cmnd->packet = (void *)p; cmnd->packet = (void *)p;
Genode::uint32_t be_block_nr = bswap<Genode::uint32_t>(block_nr); Genode::uint32_t be_block_nr = host_to_big_endian<Genode::uint32_t>(block_nr);
memcpy(&cmnd->cmnd[2], &be_block_nr, 4); memcpy(&cmnd->cmnd[2], &be_block_nr, 4);
/* transfer one block */ /* transfer one block */
Genode::uint16_t be_block_count = bswap<Genode::uint16_t>(block_count); Genode::uint16_t be_block_count = host_to_big_endian<Genode::uint16_t>(block_count);
memcpy(&cmnd->cmnd[7], &be_block_count, 2); memcpy(&cmnd->cmnd[7], &be_block_count, 2);
/* setup command */ /* setup command */

View File

@ -172,13 +172,13 @@ class Net::Arp_packet
* \return link layer type (Arp_packet::Hardware_type). * \return link layer type (Arp_packet::Hardware_type).
*/ */
Genode::uint16_t hardware_address_type() { Genode::uint16_t hardware_address_type() {
return bswap(_hw_addr_type); } return host_to_big_endian(_hw_addr_type); }
/** /**
* \return network/internet layer type (Ether_frame::EtherType). * \return network/internet layer type (Ether_frame::EtherType).
*/ */
Genode::uint16_t protocol_address_type() { Genode::uint16_t protocol_address_type() {
return bswap(_prot_addr_type); } return host_to_big_endian(_prot_addr_type); }
/** /**
* \return size in bytes of hardware address. * \return size in bytes of hardware address.
@ -193,7 +193,7 @@ class Net::Arp_packet
/** /**
* \return operation code (Arp_packet::Opcode). * \return operation code (Arp_packet::Opcode).
*/ */
Genode::uint16_t opcode() { return bswap(_opcode); } Genode::uint16_t opcode() { return host_to_big_endian(_opcode); }
/** /**
* \return source MAC address. * \return source MAC address.
@ -230,7 +230,7 @@ class Net::Arp_packet
* \param opcode Arp_packet::Opcode to set. * \param opcode Arp_packet::Opcode to set.
*/ */
void opcode(Genode::uint16_t opcode) { void opcode(Genode::uint16_t opcode) {
_opcode = bswap(opcode); } _opcode = host_to_big_endian(opcode); }
/** /**
* Set source MAC address. * Set source MAC address.
@ -274,8 +274,8 @@ class Net::Arp_packet
* address resolution with respect to IPv4 addresses. * address resolution with respect to IPv4 addresses.
*/ */
bool ethernet_ipv4() { bool ethernet_ipv4() {
return ( bswap(_hw_addr_type) == ETHERNET return ( host_to_big_endian(_hw_addr_type) == ETHERNET
&& bswap(_prot_addr_type) == Ethernet_frame::IPV4 && host_to_big_endian(_prot_addr_type) == Ethernet_frame::IPV4
&& _hw_addr_sz == Ethernet_frame::ADDR_LEN && _hw_addr_sz == Ethernet_frame::ADDR_LEN
&& _prot_addr_sz == Ipv4_packet::ADDR_LEN); && _prot_addr_sz == Ipv4_packet::ADDR_LEN);
} }

View File

@ -190,8 +190,8 @@ class Net::Dhcp_packet
Genode::uint8_t htype() { return _htype; } Genode::uint8_t htype() { return _htype; }
Genode::uint8_t hlen() { return _hlen; } Genode::uint8_t hlen() { return _hlen; }
Genode::uint8_t hops() { return _hops; } Genode::uint8_t hops() { return _hops; }
Genode::uint32_t xid() { return bswap(_xid); } Genode::uint32_t xid() { return host_to_big_endian(_xid); }
Genode::uint16_t secs() { return bswap(_secs); } Genode::uint16_t secs() { return host_to_big_endian(_secs); }
bool broadcast() { return _flags & BROADCAST; } bool broadcast() { return _flags & BROADCAST; }
@ -233,8 +233,8 @@ class Net::Dhcp_packet
void htype(Genode::uint8_t htype) { _htype = htype; } void htype(Genode::uint8_t htype) { _htype = htype; }
void hlen(Genode::uint8_t hlen) { _hlen = hlen; } void hlen(Genode::uint8_t hlen) { _hlen = hlen; }
void hops(Genode::uint8_t hops) { _hops = hops; } void hops(Genode::uint8_t hops) { _hops = hops; }
void xid(Genode::uint32_t xid) { _xid = bswap(_xid); } void xid(Genode::uint32_t xid) { _xid = host_to_big_endian(_xid); }
void secs(Genode::uint16_t secs) { _secs = bswap(_secs); } void secs(Genode::uint16_t secs) { _secs = host_to_big_endian(_secs); }
void broadcast(bool broadcast) { void broadcast(bool broadcast) {
_flags = broadcast ? BROADCAST : 0; } _flags = broadcast ? BROADCAST : 0; }

View File

@ -132,7 +132,7 @@ class Net::Ethernet_frame
/** /**
* \return EtherType - type of encapsulated protocol. * \return EtherType - type of encapsulated protocol.
*/ */
Genode::uint16_t type() { return bswap(_type); } Genode::uint16_t type() { return host_to_big_endian(_type); }
/** /**
* \return payload data. * \return payload data.
@ -163,7 +163,7 @@ class Net::Ethernet_frame
* *
* \param type the EtherType to be set. * \param type the EtherType to be set.
*/ */
void type(Genode::uint16_t type) { _type = bswap(type); } void type(Genode::uint16_t type) { _type = host_to_big_endian(type); }
/*************** /***************

View File

@ -140,8 +140,8 @@ class Net::Ipv4_packet
bool high_reliability() { return _diff_service & RELIABILITY;} bool high_reliability() { return _diff_service & RELIABILITY;}
bool minimize_monetary_cost() { return _diff_service & COST; } bool minimize_monetary_cost() { return _diff_service & COST; }
Genode::uint16_t total_length() { return bswap(_total_length); } Genode::uint16_t total_length() { return host_to_big_endian(_total_length); }
Genode::uint16_t identification() { return bswap(_identification); } Genode::uint16_t identification() { return host_to_big_endian(_identification); }
bool no_fragmentation() { return _flags & NO_FRAGMENT; } bool no_fragmentation() { return _flags & NO_FRAGMENT; }
bool more_fragments() { return _flags & MORE_FRAGMENTS; } bool more_fragments() { return _flags & MORE_FRAGMENTS; }
@ -150,7 +150,7 @@ class Net::Ipv4_packet
Genode::uint8_t time_to_live() { return _time_to_live; } Genode::uint8_t time_to_live() { return _time_to_live; }
Genode::uint8_t protocol() { return _protocol; } Genode::uint8_t protocol() { return _protocol; }
Genode::uint16_t checksum() { return bswap(_header_checksum); } Genode::uint16_t checksum() { return host_to_big_endian(_header_checksum); }
Ipv4_address dst() { return Ipv4_address(&_dst_addr); } Ipv4_address dst() { return Ipv4_address(&_dst_addr); }
Ipv4_address src() { return Ipv4_address(&_src_addr); } Ipv4_address src() { return Ipv4_address(&_src_addr); }

View File

@ -75,10 +75,10 @@ class Net::Udp_packet
** UDP field read-accessors ** ** UDP field read-accessors **
******************************/ ******************************/
Genode::uint16_t src_port() { return bswap(_src_port); } Genode::uint16_t src_port() { return host_to_big_endian(_src_port); }
Genode::uint16_t dst_port() { return bswap(_dst_port); } Genode::uint16_t dst_port() { return host_to_big_endian(_dst_port); }
Genode::uint16_t length() { return bswap(_length); } Genode::uint16_t length() { return host_to_big_endian(_length); }
Genode::uint16_t checksum() { return bswap(_checksum); } Genode::uint16_t checksum() { return host_to_big_endian(_checksum); }
void* data() { return &_data; } void* data() { return &_data; }
@ -124,7 +124,7 @@ class Net::Udp_packet
sum += s + d; sum += s + d;
} }
Genode::uint8_t prot[] = { 0, IP_ID }; Genode::uint8_t prot[] = { 0, IP_ID };
sum += bswap(*(Genode::uint16_t*)&prot) + length(); sum += host_to_big_endian(*(Genode::uint16_t*)&prot) + length();
/* /*
* sum up udp packet itself * sum up udp packet itself
@ -132,13 +132,13 @@ class Net::Udp_packet
unsigned max = (length() & 1) ? (length() - 1) : length(); unsigned max = (length() & 1) ? (length() - 1) : length();
Genode::uint16_t *udp = (Genode::uint16_t*) this; Genode::uint16_t *udp = (Genode::uint16_t*) this;
for (unsigned i = 0; i < max; i=i+2) for (unsigned i = 0; i < max; i=i+2)
sum += bswap(*udp++); sum += host_to_big_endian(*udp++);
/* if udp length is odd, append a zero byte */ /* if udp length is odd, append a zero byte */
if (length() & 1) { if (length() & 1) {
Genode::uint8_t last[] = Genode::uint8_t last[] =
{ *((Genode::uint8_t*)this + (length()-1)), 0 }; { *((Genode::uint8_t*)this + (length()-1)), 0 };
sum += bswap(*(Genode::uint16_t*)&last); sum += host_to_big_endian(*(Genode::uint16_t*)&last);
} }
/* /*
@ -149,7 +149,7 @@ class Net::Udp_packet
sum = (sum & 0xffff) + (sum >> 16); sum = (sum & 0xffff) + (sum >> 16);
/* one's complement of sum */ /* one's complement of sum */
_checksum = bswap((Genode::uint16_t) ~sum); _checksum = host_to_big_endian((Genode::uint16_t) ~sum);
} }
} __attribute__((packed)); } __attribute__((packed));

View File

@ -17,7 +17,7 @@
#include <base/stdint.h> #include <base/stdint.h>
template <typename T> template <typename T>
inline T bswap(T x) inline T host_to_big_endian(T x)
{ {
Genode::uint8_t v[sizeof(T)]; Genode::uint8_t v[sizeof(T)];
for (unsigned i=0; i<sizeof(T); i++) { for (unsigned i=0; i<sizeof(T); i++) {