Lines Matching refs:iphdr

140  * @param iphdr the IP header of the input packet
144 static struct netif *ip_forward(struct pbuf *p, struct ip_hdr *iphdr,
151 netif = ip_route((struct ip_addr *) &(iphdr->dest));
155 iphdr->dest.addr));
169 IPH_TTL_SET(iphdr, IPH_TTL(iphdr) - 1);
171 if (IPH_TTL(iphdr) == 0) {
175 if (IPH_PROTO(iphdr) != IP_PROTO_ICMP) {
183 if (IPH_CHKSUM(iphdr) >= htons(0xffff - 0x100)) {
184 IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + htons(0x100) + 1);
186 IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + htons(0x100));
190 iphdr->dest.addr));
198 netif->output(netif, p, (struct ip_addr *) &(iphdr->dest));
219 struct ip_hdr *iphdr;
232 iphdr = p->payload;
233 if (IPH_V(iphdr) != 4) {
236 IPH_V(iphdr)));
246 iphdr_hlen = IPH_HL(iphdr);
250 iphdr_len = ntohs(IPH_LEN(iphdr));
275 if (!hwcxs_good && inet_chksum(iphdr, iphdr_hlen) != 0) {
279 inet_chksum(iphdr, iphdr_hlen)));
296 if (ip_addr_ismulticast(&(iphdr->dest))) {
298 && (igmp_lookfor_group(inp, &(iphdr->dest)))) {
314 ("ip_input: iphdr->dest 0x%" X32_F " netif->ip_addr 0x%"
316 iphdr->dest.addr, netif->ip_addr.addr,
317 iphdr->dest.addr & netif->netmask.addr,
319 iphdr->dest.addr & ~(netif->netmask.addr)));
324 if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr)) ||
326 ip_addr_isbroadcast(&(iphdr->dest), netif)) {
353 if (IPH_PROTO(iphdr) == IP_PROTO_UDP) {
357 ntohs(((struct udp_hdr *) ((u8_t *) iphdr +
359 if (ntohs(((struct udp_hdr *) ((u8_t *) iphdr + iphdr_hlen))->dest)
375 if ((ip_addr_isbroadcast(&(iphdr->src), inp)) ||
376 (ip_addr_ismulticast(&(iphdr->src)))) {
396 if (!ip_addr_isbroadcast(&(iphdr->dest), inp)) {
398 ip_forward(p, iphdr, inp);
409 if ((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {
414 "), calling ip_reass()\n", ntohs(IPH_ID(iphdr)),
415 p->tot_len, ntohs(IPH_LEN(iphdr)),
416 ! !(IPH_OFFSET(iphdr) & htons(IP_MF)),
417 (ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK) * 8));
424 iphdr = p->payload;
430 ntohs(IPH_OFFSET(iphdr))));
442 if ((iphdr_hlen > IP_HLEN && (IPH_PROTO(iphdr) != IP_PROTO_IGMP)) {
465 current_header = iphdr;
473 switch (IPH_PROTO(iphdr)) {
497 igmp_input(p, inp, &(iphdr->dest));
503 if (!ip_addr_isbroadcast(&(iphdr->dest), inp) &&
504 !ip_addr_ismulticast(&(iphdr->dest))) {
505 p->payload = iphdr;
513 IPH_PROTO(iphdr)));
571 struct ip_hdr *iphdr;
613 iphdr = p->payload;
617 IPH_TTL_SET(iphdr, ttl);
618 IPH_PROTO_SET(iphdr, proto);
620 ip_addr_set(&(iphdr->dest), dest);
622 IPH_VHLTOS_SET(iphdr, 4, ip_hlen / 4, tos);
623 IPH_LEN_SET(iphdr, htons(p->tot_len));
624 IPH_OFFSET_SET(iphdr, 0);
625 IPH_ID_SET(iphdr, htons(ip_id));
629 ip_addr_set(&(iphdr->src), &(netif->ip_addr));
631 ip_addr_set(&(iphdr->src), src);
634 IPH_CHKSUM_SET(iphdr, 0);
639 IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, ip_hlen));
644 iphdr = p->payload;
645 dest = &(iphdr->dest);
755 struct ip_hdr *iphdr = p->payload;
758 payload = (u8_t *) iphdr + IP_HLEN;
764 " | (v, hl, tos, len)\n", IPH_V(iphdr), IPH_HL(iphdr),
765 IPH_TOS(iphdr), ntohs(IPH_LEN(iphdr))));
769 U16_F " | (id, flags, offset)\n", ntohs(IPH_ID(iphdr)),
770 ntohs(IPH_OFFSET(iphdr)) >> 15 & 1,
771 ntohs(IPH_OFFSET(iphdr)) >> 14 & 1,
772 ntohs(IPH_OFFSET(iphdr)) >> 13 & 1,
773 ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK));
777 " | (ttl, proto, chksum)\n", IPH_TTL(iphdr),
778 IPH_PROTO(iphdr), ntohs(IPH_CHKSUM(iphdr))));
782 " | (src)\n", ip4_addr1(&iphdr->src), ip4_addr2(&iphdr->src),
783 ip4_addr3(&iphdr->src), ip4_addr4(&iphdr->src)));
787 " | (dest)\n", ip4_addr1(&iphdr->dest),
788 ip4_addr2(&iphdr->dest), ip4_addr3(&iphdr->dest),
789 ip4_addr4(&iphdr->dest)));