Go to the documentation of this file.
58 memset(
data, 0, ETH_ADDR_LEN);
61 EthAddr::EthAddr(
const uint8_t
ea[ETH_ADDR_LEN])
63 for (
int i = 0;
i < ETH_ADDR_LEN; ++
i)
67 EthAddr::EthAddr(
const eth_addr &
ea)
69 for (
int i = 0;
i < ETH_ADDR_LEN; ++
i)
73 EthAddr::EthAddr(
const std::string &
addr)
79 EthAddr::operator=(
const eth_addr &
ea)
86 EthAddr::operator=(
const std::string &
addr)
93 EthAddr::parse(
const std::string &
addr)
97 int bytes[ETH_ADDR_LEN == 6 ? ETH_ADDR_LEN : -1];
98 if (sscanf(
addr.c_str(),
"%x:%x:%x:%x:%x:%x", &bytes[0], &bytes[1],
99 &bytes[2], &bytes[3], &bytes[4], &bytes[5]) != ETH_ADDR_LEN) {
100 memset(
data, 0xff, ETH_ADDR_LEN);
104 for (
int i = 0;
i < ETH_ADDR_LEN; ++
i) {
105 if (bytes[
i] & ~0xff) {
106 memset(
data, 0xff, ETH_ADDR_LEN);
115 EthAddr::string()
const
125 return !memcmp(left.
bytes(), right.
bytes(), ETH_ADDR_LEN);
131 const uint8_t *
a =
ea.addr();
132 ccprintf(stream,
"%x:%x:%x:%x:%x:%x",
a[0],
a[1],
a[2],
a[3],
a[4],
a[5]);
137 IpAddress::string()
const
147 return left.
ip() == right.
ip();
153 uint32_t
ip =
ia.ip();
155 (uint8_t)(
ip >> 24), (uint8_t)(
ip >> 16),
156 (uint8_t)(
ip >> 8), (uint8_t)(
ip >> 0));
161 IpNetmask::string()
const
171 return (left.
ip() == right.
ip()) &&
183 IpWithPort::string()
const
193 return (left.
ip() == right.
ip()) && (left.
port() == right.
port());
207 return ip_cksum_carry(
sum);
213 int tcplen =
ip->len() -
ip->hlen();
214 int sum = ip_cksum_add(
ip->payload(), tcplen, 0);
215 sum = ip_cksum_add(&
ip->ip_src, 8,
sum);
216 sum += htons(
ip->ip_p + tcplen);
217 return ip_cksum_carry(
sum);
223 int tcplen =
ip6->plen() -
ip6->extensionLength();
224 int sum = ip_cksum_add(
ip6->payload(), tcplen, 0);
226 sum += htons(
ip6->proto() + tcplen);
227 return ip_cksum_carry(
sum);
238 panic(
"Unrecognized IP packet format");
252 panic(
"Unrecognized IP packet format");
262 const uint8_t *
data = bytes() +
sizeof(
struct ip_hdr);
263 int all = hlen() -
sizeof(
struct ip_hdr);
278 #define IP6_EXTENSION(nxt) (nxt == IP_PROTO_HOPOPTS) ? true : \
279 (nxt == IP_PROTO_ROUTING) ? true : \
280 (nxt == IP_PROTO_FRAGMENT) ? true : \
281 (nxt == IP_PROTO_AH) ? true : \
282 (nxt == IP_PROTO_ESP) ? true: \
283 (nxt == IP_PROTO_DSTOPTS) ? true : false
289 Ip6Hdr::extensionLength()
const
291 const uint8_t *
data = bytes() + IP6_HDR_LEN;
292 uint8_t nxt = ip6_nxt;
312 Ip6Hdr::getExt(uint8_t ext_type)
const
314 const uint8_t *
data = bytes() + IP6_HDR_LEN;
315 uint8_t nxt = ip6_nxt;
321 if (nxt == ext_type) {
330 return (
const Ip6Opt*)opt;
338 Ip6Hdr::proto()
const
340 const uint8_t *
data = bytes() + IP6_HDR_LEN;
341 uint8_t nxt = ip6_nxt;
359 const uint8_t *
data = bytes() +
sizeof(
struct tcp_hdr);
360 int all = off() -
sizeof(
struct tcp_hdr);
383 split_point =
ip.pstart();
387 split_point =
tcp.pstart();
391 split_point = udp.
pstart();
393 split_point =
ip6.pstart();
397 split_point =
tcp.pstart();
400 split_point = udp.
pstart();
const uint8_t * bytes() const
const uint8_t * bytes() const
#define IP6_EXTENSION(nxt)
ostream & operator<<(ostream &stream, const IpWithPort &iwp)
uint16_t __tu_cksum6(const Ip6Ptr &ip6)
uint16_t __tu_cksum(const IpPtr &ip)
bool operator==(const IpWithPort &left, const IpWithPort &right)
std::shared_ptr< EthPacketData > EthPacketPtr
Overload hash function for BasicBlockRange type.
void ccprintf(cp::Print &print)
const EthPacketPtr packet() const
int hsplit(const EthPacketPtr &ptr)
uint16_t cksum(const UdpPtr &udp)
#define panic(...)
This implements a cprintf based panic() function.
Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17