81 for (; len > 1; len -= 2, p += 2)
88 sum = (sum & 0xffff) + (sum >> 16);
90 return htons(~sum & 0xffff);
117 for (
size_t i = 0; i <
sizeof(pseudo); i += 2)
118 sum += (
uint32_t) p[i] << 8 | p[i + 1];
120 for (p = data; len > 1; len -= 2, p += 2)
127 sum = (sum & 0xffff) + (sum >> 16);
129 return htons(~sum & 0xffff);
int ether_output(struct netif *netif, const uint8_t dst[6], uint16_t type, struct netbuf *nb)
Sends a frame: adds its Ethernet header and gives it to the interface.
uint16_t inet_checksum(const void *data, size_t len)
Computes the Internet checksum (RFC 1071): the ones' complement of the ones' complement sum of the da...
void ether_input(struct netif *netif, struct netbuf *nb)
Takes in a frame that an interface received, and passes it to ARP or IPv4.
void ipv4_input(struct netif *netif, struct netbuf *nb, const uint8_t src_mac[6])
Takes in an IPv4 packet that an interface received, and passes it to its protocol.
uint16_t inet_checksum_pseudo(uint32_t src, uint32_t dst, uint8_t proto, const void *data, size_t len)
Computes the Internet checksum of data with the IPv4 pseudo-header before it (the addresses,...
void arp_input(struct netif *netif, struct netbuf *nb)
Takes in an ARP packet: the sender's address is recorded, and a request for our address is answered.
void * memcpy(void *dst, const void *src, size_t n)
Copies n bytes; dst and src must not overlap.
static void * netbuf_push(struct netbuf *nb, size_t size)
Makes room for a header of size bytes before the data, and returns it.
static void * netbuf_pull(struct netbuf *nb, size_t size)
Takes the header of size bytes off the front of the packet, and returns it, or NULL if the packet is ...
void netbuf_free(struct netbuf *nb)
Frees a netbuf.
int netif_output(struct netif *netif, struct netbuf *nb)
Sends a frame through an interface's driver.
unsigned short int uint16_t
An Ethernet frame's header.
A network interface (net/netif.c): a device that sends and receives Ethernet frames,...
struct netif::@020302303320120142126121344055047003105154122231 stats