| 1056 | } |
| 1057 | |
| 1058 | void |
| 1059 | in_delayed_cksum(struct mbuf *m) |
| 1060 | { |
| 1061 | struct ip *ip; |
| 1062 | struct udphdr *uh; |
| 1063 | uint16_t cklen, csum, offset; |
| 1064 | |
| 1065 | ip = mtod(m, struct ip *); |
| 1066 | offset = ip->ip_hl << 2 ; |
| 1067 | |
| 1068 | if (m->m_pkthdr.csum_flags & CSUM_UDP) { |
| 1069 | /* if udp header is not in the first mbuf copy udplen */ |
| 1070 | if (offset + sizeof(struct udphdr) > m->m_len) { |
| 1071 | m_copydata(m, offset + offsetof(struct udphdr, |
| 1072 | uh_ulen), sizeof(cklen), (caddr_t)&cklen); |
| 1073 | cklen = ntohs(cklen); |
| 1074 | } else { |
| 1075 | uh = (struct udphdr *)mtodo(m, offset); |
| 1076 | cklen = ntohs(uh->uh_ulen); |
| 1077 | } |
| 1078 | csum = in_cksum_skip(m, cklen + offset, offset); |
| 1079 | if (csum == 0) |
| 1080 | csum = 0xffff; |
| 1081 | } else { |
| 1082 | cklen = ntohs(ip->ip_len); |
| 1083 | csum = in_cksum_skip(m, cklen, offset); |
| 1084 | } |
| 1085 | offset += m->m_pkthdr.csum_data; /* checksum offset */ |
| 1086 | |
| 1087 | if (offset + sizeof(csum) > m->m_len) |
| 1088 | m_copyback(m, offset, sizeof(csum), (caddr_t)&csum); |
| 1089 | else |
| 1090 | *(u_short *)mtodo(m, offset) = csum; |
| 1091 | } |
| 1092 | |
| 1093 | /* |
| 1094 | * IP socket option processing. |
no test coverage detected