42#ifndef __BASE_INET_HH__
43#define __BASE_INET_HH__
63#include "dnet/route.h"
98 int size()
const {
return sizeof(eth_addr); }
118 bool isBroadcast =
true;
119 for (
int i = 0;
i < ETH_ADDR_LEN; ++
i) {
120 isBroadcast = isBroadcast &&
data[
i] == 0xff;
130 std::string
string()
const;
135 operator uint64_t()
const
138 reg |= ((uint64_t)
data[0]) << 40;
139 reg |= ((uint64_t)
data[1]) << 32;
140 reg |= ((uint64_t)
data[2]) << 24;
141 reg |= ((uint64_t)
data[3]) << 16;
142 reg |= ((uint64_t)
data[4]) << 8;
143 reg |= ((uint64_t)
data[5]) << 0;
159 bool isVlan()
const {
return (ntohs(eth_type) == ETH_TYPE_8021Q); }
162 return ntohs(eth_type);
166 return ntohs(*((uint16_t*)(((uint8_t *)
this) + 16)));
170 return ntohs(*((uint16_t*)(((uint8_t *)
this) + 14)));
180 return sizeof(eth_hdr);
182 return (
sizeof(eth_hdr)+4);
185 const uint8_t *
bytes()
const {
return (
const uint8_t *)
this; }
187 uint8_t *
bytes() {
return (uint8_t *)
this; }
227 operator bool()
const {
return (
p !=
nullptr); }
228 int off()
const {
return 0; }
260 std::string
string()
const;
279 IpNetmask(
const uint32_t __ip,
const uint8_t __netmask) :
288 std::string
string()
const;
316 std::string
string()
const;
331 uint8_t
hlen()
const {
return ip_hl * 4; }
332 uint8_t
tos()
const {
return ip_tos; }
333 uint16_t
len()
const {
return ntohs(ip_len); }
334 uint16_t
id()
const {
return ntohs(ip_id); }
336 uint16_t
frag_off()
const {
return ntohs(ip_off) & 0x1fff; }
337 uint8_t
ttl()
const {
return ip_ttl; }
338 uint8_t
proto()
const {
return ip_p; }
339 uint16_t
sum()
const {
return ip_sum; }
340 uint32_t
src()
const {
return ntohl(ip_src); }
341 uint32_t
dst()
const {
return ntohl(ip_dst); }
344 void id(uint16_t _id) { ip_id = htons(_id); }
345 void len(uint16_t _len) { ip_len = htons(_len); }
350 const uint8_t *
bytes()
const {
return (
const uint8_t *)
this; }
352 uint8_t *
bytes() {
return (uint8_t *)
this; }
371 if (eth->
type() == ETH_TYPE_IP)
399 {
return (
const IpHdr *)(
p->data +
sizeof(eth_hdr) +
416 operator bool()
const {
return (
p !=
nullptr); }
429 uint8_t
type()
const {
return opt_type; }
430 uint8_t
typeNumber()
const {
return IP_OPT_NUMBER(opt_type); }
431 uint8_t
typeClass()
const {
return IP_OPT_CLASS(opt_type); }
432 uint8_t
typeCopied()
const {
return IP_OPT_COPIED(opt_type); }
433 uint8_t
len()
const {
return IP_OPT_TYPEONLY(
type()) ? 1 : opt_len; }
439 const uint8_t *
data()
const {
return opt_data.data8; }
443 void ts(ip_opt_data_ts &
ts)
const;
444 uint16_t
satid()
const {
return ntohs(opt_data.satid); }
445 uint16_t
mtup()
const {
return ntohs(opt_data.mtu); }
446 uint16_t
mtur()
const {
return ntohs(opt_data.mtu); }
447 void tr(ip_opt_data_tr &
tr)
const;
448 uint16_t
rtralt()
const {
return ntohs(opt_data.rtralt); }
459 uint32_t
flow()
const {
return ntohl(ip6_flow); }
460 uint16_t
plen()
const {
return ntohs(ip6_plen); }
461 uint16_t
hlen()
const {
return IP6_HDR_LEN; }
462 uint8_t
nxt()
const {
return ip6_nxt; }
463 uint8_t
hlim()
const {
return ip6_hlim; }
465 const uint8_t*
src()
const {
return ip6_src.data; }
466 const uint8_t*
dst()
const {
return ip6_dst.data; }
473 uint8_t
proto()
const;
475 void plen(uint16_t _plen) { ip6_plen = htons(_plen); }
478 const uint8_t *
bytes()
const {
return (
const uint8_t *)
this; }
481 uint8_t *
bytes() {
return (uint8_t *)
this; }
501 if (eth->
type() == ETH_TYPE_IPV6)
525 {
return (
const Ip6Hdr *)(
p->data +
sizeof(eth_hdr)
535 {
set(ptr);
return *
this; }
537 {
set(ptr.
p);
return *
this; }
539 {
p = ptr.
p;
return *
this; }
549 operator bool()
const {
return (
p !=
nullptr); }
622 uint16_t
sport()
const {
return ntohs(th_sport); }
623 uint16_t
dport()
const {
return ntohs(th_dport); }
624 uint32_t
seq()
const {
return ntohl(th_seq); }
625 uint32_t
ack()
const {
return ntohl(th_ack); }
626 uint8_t
off()
const {
return th_off*4; }
627 uint8_t
flags()
const {
return th_flags & 0x3f; }
628 uint16_t
win()
const {
return ntohs(th_win); }
629 uint16_t
sum()
const {
return th_sum; }
630 uint16_t
urp()
const {
return ntohs(th_urp); }
633 void seq(uint32_t _seq) { th_seq = htonl(_seq); }
634 void flags(uint8_t _flags) { th_flags = _flags; }
639 const uint8_t *
bytes()
const {
return (
const uint8_t *)
this; }
641 uint8_t *
bytes() {
return (uint8_t *)
this; }
654 if (ptr && ptr->
proto() == IP_PROTO_TCP)
661 if (ptr && ptr->
proto() == IP_PROTO_TCP)
691 {
set(
i);
return *
this; }
693 {
set(
t.p,
t._off);
return *
this; }
703 operator bool()
const {
return (
p !=
nullptr); }
716 uint8_t
type()
const {
return opt_type; }
717 uint8_t
len()
const {
return TCP_OPT_TYPEONLY(
type()) ? 1 : opt_len; }
721 const uint8_t *
data()
const {
return opt_data.data8; }
723 uint16_t
mss()
const {
return ntohs(opt_data.mss); }
724 uint8_t
wscale()
const {
return opt_data.wscale; }
725 uint32_t
echo()
const {
return ntohl(opt_data.echo); }
726 uint32_t
tsval()
const {
return ntohl(opt_data.timestamp[0]); }
727 uint32_t
tsecr()
const {
return ntohl(opt_data.timestamp[1]); }
728 uint32_t
cc()
const {
return ntohl(opt_data.cc); }
729 uint8_t
cksum()
const{
return opt_data.cksum; }
730 const uint8_t *
md5()
const {
return opt_data.md5; }
733 const uint8_t *
bytes()
const {
return (
const uint8_t *)
this; }
735 uint8_t *
bytes() {
return (uint8_t *)
this; }
744 uint16_t
sport()
const {
return ntohs(uh_sport); }
745 uint16_t
dport()
const {
return ntohs(uh_dport); }
746 uint16_t
len()
const {
return ntohs(uh_ulen); }
747 uint16_t
sum()
const {
return uh_sum; }
750 void len(uint16_t _len) { uh_ulen = htons(_len); }
752 int size()
const {
return sizeof(udp_hdr); }
753 const uint8_t *
bytes()
const {
return (
const uint8_t *)
this; }
755 uint8_t *
bytes() {
return (uint8_t *)
this; }
768 if (ptr && ptr->
proto() == IP_PROTO_UDP)
775 if (ptr && ptr->
proto() == IP_PROTO_UDP)
805 {
set(
t.p,
t._off);
return *
this; }
815 operator bool()
const {
return (
p !=
nullptr); }
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
const EthHdr * operator->() const
const EthHdr & operator*() const
const Ip6Hdr * operator->() const
const Ip6Hdr & operator*() const
void set(const EthPacketPtr &ptr)
const Ip6Hdr * get() const
const IpPtr & operator=(const EthPtr &ptr)
void set(const EthPacketPtr &ptr)
const IpPtr & operator=(const IpPtr &ptr)
const IpPtr & operator=(const EthPacketPtr &ptr)
void set(const EthPacketPtr &ptr, int offset)
void set(const Ip6Ptr &ptr)
const TcpHdr * operator->() const
const TcpHdr * get() const
const TcpHdr & operator*() const
void set(const IpPtr &ptr)
UdpPtr(const Ip6Ptr &ptr)
const UdpHdr * get() const
UdpPtr(const UdpPtr &ptr)
const UdpHdr & operator*() const
void set(const Ip6Ptr &ptr)
void set(const IpPtr &ptr)
void set(const EthPacketPtr &ptr, int offset)
const UdpHdr * operator->() const
Ip6Ptr(const EthPacketPtr &ptr)
const EthPacketPtr packet() const
const EthPacketPtr packet() const
const TcpPtr & operator=(const TcpPtr &t)
uint16_t cksum(const IpPtr &ptr)
const IpHdr * get() const
uint16_t __tu_cksum6(const Ip6Ptr &ip6)
int hsplit(const EthPacketPtr &ptr)
const EthPacketPtr packet() const
const IpHdr & operator*() const
const Ip6Ptr & operator=(const EthPacketPtr &ptr)
const Ip6Ptr & operator=(const EthPtr &ptr)
uint16_t __tu_cksum(const IpPtr &ip)
std::string string() const
const TcpPtr & operator=(const IpPtr &i)
const IpHdr * operator->() const
const EthPtr & operator=(const EthPacketPtr &ptr)
EthPtr(const EthPacketPtr &ptr)
const EthPacketPtr packet() const
const uint8_t * addr() const
Ip6Ptr(const Ip6Ptr &ptr)
bool operator==(const EthAddr &left, const EthAddr &right)
TcpPtr(const Ip6Ptr &ptr)
const uint8_t * bytes() const
const UdpPtr & operator=(const UdpPtr &t)
const Ip6Ptr & operator=(const Ip6Ptr &ptr)
std::string string() const
Ip6Ptr(const EthPtr &ptr)
const EthPacketPtr packet() const
const UdpPtr & operator=(const IpPtr &i)
std::ostream & operator<<(std::ostream &stream, const EthAddr &ea)
const EthAddr & operator=(const eth_addr &ea)
IpPtr(const EthPacketPtr &ptr)
IpAddress(const uint32_t __ip)
TcpPtr(const TcpPtr &ptr)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::shared_ptr< EthPacketData > EthPacketPtr
void parse(const std::string &addr)
const uint8_t * bytes() const
const uint8_t * payload() const
const EthAddr & dst() const
const EthAddr & src() const
const Ip6Opt * dstOptExt() const
const uint8_t * src() const
const Ip6Opt * rtTypeExt() const
const uint8_t * dst() const
const Ip6Opt * getExt(uint8_t ext) const
const uint8_t * bytes() const
void plen(uint16_t _plen)
const Ip6Opt * fragmentExt() const
int extensionLength() const
const uint8_t * payload() const
uint16_t fragmentOfflg() const
uint8_t dstOptType() const
const uint8_t * dstOptAddr() const
uint32_t fragmentIdent() const
uint8_t rtType2Type() const
uint8_t dstOptLength() const
uint8_t rtType2SegLft() const
const uint8_t * rtType2Addr() const
const uint8_t * bytes() const
uint16_t frag_flags() const
const uint8_t * payload() const
uint16_t frag_off() const
bool options(std::vector< const IpOpt * > &vec) const
IpNetmask(const uint32_t __ip, const uint8_t __netmask)
std::string string() const
bool isNumber(int num) const
uint8_t typeNumber() const
bool isClass(int cls) const
uint8_t typeClass() const
void sdb(std::vector< uint32_t > &vec) const
void ssrr(ip_opt_data_rr &rr) const
void ts(ip_opt_data_ts &ts) const
const uint8_t * data() const
uint8_t typeCopied() const
void sec(ip_opt_data_sec &sec) const
void tr(ip_opt_data_tr &tr) const
bool isCopied(int cpy) const
void lsrr(ip_opt_data_rr &rr) const
std::string string() const
IpWithPort(const uint32_t __ip, const uint16_t __port)
bool options(std::vector< const TcpOpt * > &vec) const
const uint8_t * bytes() const
void flags(uint8_t _flags)
const uint8_t * payload() const
const uint8_t * payload() const
const uint8_t * bytes() const
const uint8_t * md5() const
bool isopt(int opt) const
const uint8_t * data() const
const uint8_t * bytes() const
const uint8_t * payload() const
union gem5::networking::ip6_opt_hdr::@46 ext_data