Go to the documentation of this file.
42 #ifndef __BASE_INET_HH__
43 #define __BASE_INET_HH__
57 #include "dnet/addr.h"
59 #include "dnet/icmp.h"
62 #include "dnet/intf.h"
63 #include "dnet/route.h"
65 #include "dnet/blob.h"
66 #include "dnet/rand.h"
99 int size()
const {
return sizeof(eth_addr); }
119 bool isBroadcast =
true;
120 for (
int i = 0;
i < ETH_ADDR_LEN; ++
i) {
121 isBroadcast = isBroadcast &&
data[
i] == 0xff;
131 std::string
string()
const;
136 operator uint64_t()
const
139 reg |= ((uint64_t)
data[0]) << 40;
140 reg |= ((uint64_t)
data[1]) << 32;
141 reg |= ((uint64_t)
data[2]) << 24;
142 reg |= ((uint64_t)
data[3]) << 16;
143 reg |= ((uint64_t)
data[4]) << 8;
144 reg |= ((uint64_t)
data[5]) << 0;
160 bool isVlan()
const {
return (ntohs(eth_type) == ETH_TYPE_8021Q); }
163 return ntohs(eth_type);
167 return ntohs(*((uint16_t*)(((uint8_t *)
this) + 16)));
171 return ntohs(*((uint16_t*)(((uint8_t *)
this) + 14)));
181 return sizeof(eth_hdr);
183 return (
sizeof(eth_hdr)+4);
186 const uint8_t *
bytes()
const {
return (
const uint8_t *)
this; }
188 uint8_t *
bytes() {
return (uint8_t *)
this; }
228 operator bool()
const {
return (
p !=
nullptr); }
229 int off()
const {
return 0; }
261 std::string
string()
const;
280 IpNetmask(
const uint32_t __ip,
const uint8_t __netmask) :
289 std::string
string()
const;
317 std::string
string()
const;
332 uint8_t
hlen()
const {
return ip_hl * 4; }
333 uint8_t
tos()
const {
return ip_tos; }
334 uint16_t
len()
const {
return ntohs(ip_len); }
335 uint16_t
id()
const {
return ntohs(ip_id); }
337 uint16_t
frag_off()
const {
return ntohs(ip_off) & 0x1fff; }
338 uint8_t
ttl()
const {
return ip_ttl; }
339 uint8_t
proto()
const {
return ip_p; }
340 uint16_t
sum()
const {
return ip_sum; }
341 uint32_t
src()
const {
return ntohl(ip_src); }
342 uint32_t
dst()
const {
return ntohl(ip_dst); }
345 void id(uint16_t _id) { ip_id = htons(_id); }
346 void len(uint16_t _len) { ip_len = htons(_len); }
351 const uint8_t *
bytes()
const {
return (
const uint8_t *)
this; }
353 uint8_t *
bytes() {
return (uint8_t *)
this; }
372 if (eth->
type() == ETH_TYPE_IP)
400 {
return (
const IpHdr *)(
p->data +
sizeof(eth_hdr) +
417 operator bool()
const {
return (
p !=
nullptr); }
430 uint8_t
type()
const {
return opt_type; }
431 uint8_t
typeNumber()
const {
return IP_OPT_NUMBER(opt_type); }
432 uint8_t
typeClass()
const {
return IP_OPT_CLASS(opt_type); }
433 uint8_t
typeCopied()
const {
return IP_OPT_COPIED(opt_type); }
434 uint8_t
len()
const {
return IP_OPT_TYPEONLY(
type()) ? 1 : opt_len; }
440 const uint8_t *
data()
const {
return opt_data.data8; }
441 void sec(ip_opt_data_sec &
sec)
const;
442 void lsrr(ip_opt_data_rr &
rr)
const;
443 void ssrr(ip_opt_data_rr &
rr)
const;
444 void ts(ip_opt_data_ts &
ts)
const;
445 uint16_t
satid()
const {
return ntohs(opt_data.satid); }
446 uint16_t
mtup()
const {
return ntohs(opt_data.mtu); }
447 uint16_t
mtur()
const {
return ntohs(opt_data.mtu); }
448 void tr(ip_opt_data_tr &
tr)
const;
449 uint16_t
rtralt()
const {
return ntohs(opt_data.rtralt); }
460 uint32_t
flow()
const {
return ntohl(ip6_flow); }
461 uint16_t
plen()
const {
return ntohs(ip6_plen); }
462 uint16_t
hlen()
const {
return IP6_HDR_LEN; }
463 uint8_t
nxt()
const {
return ip6_nxt; }
464 uint8_t
hlim()
const {
return ip6_hlim; }
466 const uint8_t*
src()
const {
return ip6_src.data; }
467 const uint8_t*
dst()
const {
return ip6_dst.data; }
474 uint8_t
proto()
const;
476 void plen(uint16_t _plen) { ip6_plen = htons(_plen); }
479 const uint8_t *
bytes()
const {
return (
const uint8_t *)
this; }
482 uint8_t *
bytes() {
return (uint8_t *)
this; }
502 if (eth->
type() == ETH_TYPE_IPV6)
526 {
return (
const Ip6Hdr *)(
p->data +
sizeof(eth_hdr)
536 {
set(ptr);
return *
this; }
538 {
set(ptr.
p);
return *
this; }
540 {
p = ptr.
p;
return *
this; }
550 operator bool()
const {
return (
p !=
nullptr); }
623 uint16_t
sport()
const {
return ntohs(th_sport); }
624 uint16_t
dport()
const {
return ntohs(th_dport); }
625 uint32_t
seq()
const {
return ntohl(th_seq); }
626 uint32_t
ack()
const {
return ntohl(th_ack); }
627 uint8_t
off()
const {
return th_off*4; }
628 uint8_t
flags()
const {
return th_flags & 0x3f; }
629 uint16_t
win()
const {
return ntohs(th_win); }
630 uint16_t
sum()
const {
return th_sum; }
631 uint16_t
urp()
const {
return ntohs(th_urp); }
634 void seq(uint32_t _seq) { th_seq = htonl(_seq); }
635 void flags(uint8_t _flags) { th_flags = _flags; }
640 const uint8_t *
bytes()
const {
return (
const uint8_t *)
this; }
642 uint8_t *
bytes() {
return (uint8_t *)
this; }
655 if (ptr && ptr->
proto() == IP_PROTO_TCP)
662 if (ptr && ptr->
proto() == IP_PROTO_TCP)
692 {
set(
i);
return *
this; }
694 {
set(
t.p,
t._off);
return *
this; }
704 operator bool()
const {
return (
p !=
nullptr); }
717 uint8_t
type()
const {
return opt_type; }
718 uint8_t
len()
const {
return TCP_OPT_TYPEONLY(
type()) ? 1 : opt_len; }
722 const uint8_t *
data()
const {
return opt_data.data8; }
724 uint16_t
mss()
const {
return ntohs(opt_data.mss); }
725 uint8_t
wscale()
const {
return opt_data.wscale; }
726 uint32_t
echo()
const {
return ntohl(opt_data.echo); }
727 uint32_t
tsval()
const {
return ntohl(opt_data.timestamp[0]); }
728 uint32_t
tsecr()
const {
return ntohl(opt_data.timestamp[1]); }
729 uint32_t
cc()
const {
return ntohl(opt_data.cc); }
730 uint8_t
cksum()
const{
return opt_data.cksum; }
731 const uint8_t *
md5()
const {
return opt_data.md5; }
734 const uint8_t *
bytes()
const {
return (
const uint8_t *)
this; }
736 uint8_t *
bytes() {
return (uint8_t *)
this; }
745 uint16_t
sport()
const {
return ntohs(uh_sport); }
746 uint16_t
dport()
const {
return ntohs(uh_dport); }
747 uint16_t
len()
const {
return ntohs(uh_ulen); }
748 uint16_t
sum()
const {
return uh_sum; }
751 void len(uint16_t _len) { uh_ulen = htons(_len); }
753 int size()
const {
return sizeof(udp_hdr); }
754 const uint8_t *
bytes()
const {
return (
const uint8_t *)
this; }
756 uint8_t *
bytes() {
return (uint8_t *)
this; }
769 if (ptr && ptr->
proto() == IP_PROTO_UDP)
776 if (ptr && ptr->
proto() == IP_PROTO_UDP)
806 {
set(
t.p,
t._off);
return *
this; }
816 operator bool()
const {
return (
p !=
nullptr); }
839 #endif // __BASE_INET_HH__
const Ip6Opt * dstOptExt() const
const uint8_t * bytes() const
void set(const EthPacketPtr &ptr)
const UdpHdr * operator->() const
uint8_t rtType2Type() const
void ts(ip_opt_data_ts &ts) const
int extensionLength() const
uint16_t fragmentOfflg() const
std::string string() const
std::ostream & operator<<(std::ostream &stream, const EthAddr &ea)
IpAddress(const uint32_t __ip)
void tr(ip_opt_data_tr &tr) const
const EthHdr & operator*() const
uint16_t cksum(const IpPtr &ptr)
const Ip6Opt * getExt(uint8_t ext) const
int hsplit(const EthPacketPtr &ptr)
uint16_t frag_flags() const
uint8_t typeNumber() const
const UdpHdr & operator*() const
const IpPtr & operator=(const IpPtr &ptr)
void lsrr(ip_opt_data_rr &rr) const
const UdpPtr & operator=(const IpPtr &i)
bool options(std::vector< const IpOpt * > &vec) const
const uint8_t * bytes() const
uint8_t dstOptType() const
const EthPacketPtr packet() const
const TcpHdr & operator*() const
const Ip6Hdr * operator->() const
const Ip6Hdr & operator*() const
const Ip6Ptr & operator=(const EthPtr &ptr)
void set(const Ip6Ptr &ptr)
const EthAddr & dst() const
bool operator==(const EthAddr &left, const EthAddr &right)
void set(const Ip6Ptr &ptr)
const EthPacketPtr packet() const
const uint8_t * bytes() const
void set(const EthPacketPtr &ptr)
uint8_t typeCopied() const
const uint8_t * payload() const
const uint8_t * src() const
void parse(const std::string &addr)
void sec(ip_opt_data_sec &sec) const
const UdpHdr * get() const
bool options(std::vector< const TcpOpt * > &vec) const
bool isCopied(int cpy) const
const UdpPtr & operator=(const UdpPtr &t)
const IpHdr * operator->() const
IpNetmask(const uint32_t __ip, const uint8_t __netmask)
const uint8_t * md5() const
std::string string() const
const uint8_t * payload() const
std::shared_ptr< EthPacketData > EthPacketPtr
const TcpPtr & operator=(const IpPtr &i)
const Ip6Opt * rtTypeExt() const
const uint8_t * payload() const
const IpHdr & operator*() const
uint16_t __tu_cksum6(const Ip6Ptr &ip6)
const IpPtr & operator=(const EthPacketPtr &ptr)
UdpPtr(const Ip6Ptr &ptr)
uint16_t frag_off() const
const uint8_t * bytes() const
uint32_t fragmentIdent() const
const uint8_t * payload() const
UdpPtr(const UdpPtr &ptr)
const IpHdr * get() const
TcpPtr(const TcpPtr &ptr)
void flags(uint8_t _flags)
const EthAddr & operator=(const eth_addr &ea)
void set(const EthPacketPtr &ptr, int offset)
const uint8_t * data() const
Ip6Ptr(const Ip6Ptr &ptr)
const EthHdr * operator->() const
const uint8_t * dstOptAddr() const
const Ip6Ptr & operator=(const EthPacketPtr &ptr)
const uint8_t * rtType2Addr() const
bool isopt(int opt) const
const EthPtr & operator=(const EthPacketPtr &ptr)
const IpPtr & operator=(const EthPtr &ptr)
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
const EthPacketPtr packet() const
uint8_t dstOptLength() const
const Ip6Opt * fragmentExt() const
bool isNumber(int num) const
const Ip6Hdr * get() const
std::string string() const
IpPtr(const EthPacketPtr &ptr)
uint8_t rtType2SegLft() const
void ssrr(ip_opt_data_rr &rr) const
bool isClass(int cls) const
const uint8_t * bytes() const
const TcpHdr * operator->() const
const uint8_t * bytes() const
const TcpHdr * get() const
const EthPacketPtr packet() const
uint16_t __tu_cksum(const IpPtr &ip)
void set(const IpPtr &ptr)
const uint8_t * payload() const
TcpPtr(const Ip6Ptr &ptr)
std::string string() const
const uint8_t * dst() const
const TcpPtr & operator=(const TcpPtr &t)
const uint8_t * bytes() const
void plen(uint16_t _plen)
const EthPacketPtr packet() const
const Ip6Ptr & operator=(const Ip6Ptr &ptr)
const uint8_t * addr() const
const uint8_t * data() const
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const EthAddr & src() const
Ip6Ptr(const EthPacketPtr &ptr)
union gem5::networking::ip6_opt_hdr::@23 ext_data
EthPtr(const EthPacketPtr &ptr)
IpWithPort(const uint32_t __ip, const uint16_t __port)
Ip6Ptr(const EthPtr &ptr)
void set(const EthPacketPtr &ptr, int offset)
void set(const IpPtr &ptr)
void sdb(std::vector< uint32_t > &vec) const
const uint8_t * payload() const
uint8_t typeClass() const
Generated on Wed Jul 28 2021 12:10:23 for gem5 by doxygen 1.8.17