12 #include <boost/scoped_array.hpp>
15 boost::asio::io_context &io)
16 :
ProtoHandler(agent, info, io), icmp_(pkt_info_->transp.icmp) {
37 switch (
icmp_->icmp_type) {
56 uint16_t checksum =
icmp_->icmp_cksum;
57 icmp_->icmp_cksum = 0;
67 uint16_t buf_len =
pkt_info_->max_pkt_len;
70 boost::scoped_array<char> icmp_payload(
new char[
icmp_len_]);
77 len +=
EthHdr(ptr + len, buf_len - len,
82 uint16_t ip_len =
sizeof(
struct ip) + icmp_len_;
84 len +=
IpHdr(ptr + len, buf_len - len, ip_len,
85 htonl(
pkt_info_->ip_daddr.to_v4().to_ulong()),
86 htonl(
pkt_info_->ip_saddr.to_v4().to_ulong()),
90 struct icmp *hdr = (
struct icmp *) (ptr + len);
91 memcpy(ptr + len, icmp_payload.get(),
icmp_len_);
95 hdr->icmp_type = ICMP_ECHOREPLY;
InterfaceTable * interface_table() const
uint16_t Csum(uint16_t *, std::size_t, uint32_t) const
boost::shared_ptr< PktInfo > pkt_info_
IcmpHandler(Agent *agent, boost::shared_ptr< PktInfo > info, boost::asio::io_context &io)
uint16_t tx_vlan_id() const
int EthHdr(const MacAddress &src, const MacAddress &dest, const uint16_t proto)
uint32_t GetInterfaceIndex() const
void Send(uint32_t itf, uint32_t vrf, uint16_t, PktHandler::PktModuleName)
bool layer3_forwarding() const
void SendResponse(VmInterface *vm_intf)
void IcmpChecksum(char *buff, uint16_t buf_len)
void IncrStatsIntfNotInst()
IcmpProto * GetIcmpProto() const
const Interface * FindInterface(size_t index) const
void IncrStatsGwPingErr()
void IpHdr(uint16_t len, in_addr_t src, in_addr_t dest, uint8_t protocol, uint16_t id, uint8_t ttl)