mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-15 07:27:42 -04:00
IP Address utilities
This commit is contained in:
parent
e91631b2f2
commit
fbb39988eb
33
kernel/include/ip_layer.hpp
Normal file
33
kernel/include/ip_layer.hpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//=======================================================================
|
||||||
|
// Copyright Baptiste Wicht 2013-2016.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
#ifndef NET_IP_LAYER_H
|
||||||
|
#define NET_IP_LAYER_H
|
||||||
|
|
||||||
|
#include <types.hpp>
|
||||||
|
|
||||||
|
namespace network {
|
||||||
|
|
||||||
|
namespace ip {
|
||||||
|
|
||||||
|
struct address {
|
||||||
|
uint32_t address = 0;
|
||||||
|
|
||||||
|
uint8_t operator()(size_t index) const {
|
||||||
|
return (address >> ((3 - index) * 8)) & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_sub(size_t index, uint8_t value){
|
||||||
|
address |= uint32_t(value) << ((3 - index) * 8);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end of ip namespace
|
||||||
|
|
||||||
|
} // end of network namespace
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user