mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-04 18:22:08 +00:00
parent
d0f5838c61
commit
791fd9806f
@ -43,6 +43,14 @@ struct Net::Ipv4_address : Network_address<IPV4_ADDR_LEN, '.', false>
|
||||
Ipv4_address(void *src) : Network_address(src) { }
|
||||
|
||||
bool valid() const { return *this != Ipv4_address(); }
|
||||
|
||||
Genode::uint32_t to_uint32_big_endian() const;
|
||||
|
||||
static Ipv4_address from_uint32_big_endian(Genode::uint32_t ip_raw);
|
||||
|
||||
Genode::uint32_t to_uint32_little_endian() const;
|
||||
|
||||
static Ipv4_address from_uint32_little_endian(Genode::uint32_t ip_raw);
|
||||
}
|
||||
__attribute__((packed));
|
||||
|
||||
|
@ -38,6 +38,46 @@ void Net::Ipv4_packet::print(Genode::Output &output) const
|
||||
}
|
||||
|
||||
|
||||
uint32_t Ipv4_address::to_uint32_big_endian() const
|
||||
{
|
||||
return addr[0] |
|
||||
addr[1] << 8 |
|
||||
addr[2] << 16 |
|
||||
addr[3] << 24;
|
||||
}
|
||||
|
||||
|
||||
Ipv4_address Ipv4_address::from_uint32_big_endian(uint32_t ip_raw)
|
||||
{
|
||||
Ipv4_address ip;
|
||||
ip.addr[0] = ip_raw;
|
||||
ip.addr[1] = ip_raw >> 8;
|
||||
ip.addr[2] = ip_raw >> 16;
|
||||
ip.addr[3] = ip_raw >> 24;
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
||||
uint32_t Ipv4_address::to_uint32_little_endian() const
|
||||
{
|
||||
return addr[3] |
|
||||
addr[2] << 8 |
|
||||
addr[1] << 16 |
|
||||
addr[0] << 24;
|
||||
}
|
||||
|
||||
|
||||
Ipv4_address Ipv4_address::from_uint32_little_endian(uint32_t ip_raw)
|
||||
{
|
||||
Ipv4_address ip;
|
||||
ip.addr[3] = ip_raw;
|
||||
ip.addr[2] = ip_raw >> 8;
|
||||
ip.addr[1] = ip_raw >> 16;
|
||||
ip.addr[0] = ip_raw >> 24;
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
||||
struct Scanner_policy_number
|
||||
{
|
||||
static bool identifier_char(char c, unsigned i ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user