Lines Matching refs:ipr

133 ip_reasm_free(struct ip_reasm *ipr)  in ip_reasm_free()  argument
137 while ((ipq = STAILQ_FIRST(&ipr->ip_queue)) != NULL) { in ip_reasm_free()
138 STAILQ_REMOVE_HEAD(&ipr->ip_queue, ipq_next); in ip_reasm_free()
142 free(ipr->ip_pkt); in ip_reasm_free()
143 free(ipr); in ip_reasm_free()
147 ip_reasm_add(struct ip_reasm *ipr, void *pkt, struct ip *ip) in ip_reasm_add() argument
158 STAILQ_FOREACH(p, &ipr->ip_queue, ipq_next) { in ip_reasm_add()
167 STAILQ_INSERT_AFTER(&ipr->ip_queue, prev, ipq, ipq_next); in ip_reasm_add()
170 STAILQ_INSERT_HEAD(&ipr->ip_queue, ipq, ipq_next); in ip_reasm_add()
188 struct ip_reasm *ipr; in readipv4() local
288 STAILQ_FOREACH(ipr, &ire_list, ip_next) { in readipv4()
289 if (ipr->ip_src.s_addr == ip->ip_src.s_addr && in readipv4()
290 ipr->ip_dst.s_addr == ip->ip_dst.s_addr && in readipv4()
291 ipr->ip_id == ip->ip_id && in readipv4()
292 ipr->ip_proto == ip->ip_p) in readipv4()
297 if (ipr == NULL) { in readipv4()
298 if ((ipr = calloc(1, sizeof (*ipr))) == NULL) { in readipv4()
303 ipr->ip_src = ip->ip_src; in readipv4()
304 ipr->ip_dst = ip->ip_dst; in readipv4()
305 ipr->ip_id = ip->ip_id; in readipv4()
306 ipr->ip_proto = ip->ip_p; in readipv4()
307 ipr->ip_ttl = MAXTTL; in readipv4()
308 STAILQ_INIT(&ipr->ip_queue); in readipv4()
309 STAILQ_INSERT_TAIL(&ire_list, ipr, ip_next); in readipv4()
312 if (ip_reasm_add(ipr, ptr, ip) != 0) { in readipv4()
313 STAILQ_REMOVE(&ire_list, ipr, ip_reasm, ip_next); in readipv4()
314 free(ipr); in readipv4()
320 ipr->ip_total_size = (8 * (ntohs(ip->ip_off) & IP_OFFMASK)); in readipv4()
321 ipr->ip_total_size += n + sizeof (*ip); in readipv4()
322 ipr->ip_total_size += sizeof (struct ether_header); in readipv4()
324 ipr->ip_pkt = malloc(ipr->ip_total_size + 2); in readipv4()
325 if (ipr->ip_pkt == NULL) { in readipv4()
326 STAILQ_REMOVE(&ire_list, ipr, ip_reasm, ip_next); in readipv4()
327 ip_reasm_free(ipr); in readipv4()
336 if (ipr->ip_pkt == NULL) { in readipv4()
347 STAILQ_FOREACH(ipq, &ipr->ip_queue, ipq_next) { in readipv4()
349 STAILQ_REMOVE(&ire_list, ipr, ip_reasm, ip_next); in readipv4()
350 ip_reasm_free(ipr); in readipv4()
362 ipq = STAILQ_FIRST(&ipr->ip_queue); in readipv4()
364 eh = (struct ether_header *)((uintptr_t)ipr->ip_pkt + 2); in readipv4()
368 ipr->ip_hdr = (struct ip *)((uintptr_t)eh + sizeof (*eh)); in readipv4()
369 bcopy(ipq->ipq_hdr, ipr->ip_hdr, sizeof (*ipr->ip_hdr)); in readipv4()
370 ipr->ip_hdr->ip_hl = sizeof (*ipr->ip_hdr) >> 2; in readipv4()
371 ipr->ip_hdr->ip_len = htons(n); in readipv4()
372 ipr->ip_hdr->ip_sum = 0; in readipv4()
373 ipr->ip_hdr->ip_sum = in_cksum(ipr->ip_hdr, sizeof (*ipr->ip_hdr)); in readipv4()
376 ptr = (char *)((uintptr_t)ipr->ip_hdr + sizeof (*ipr->ip_hdr)); in readipv4()
377 STAILQ_FOREACH(ipq, &ipr->ip_queue, ipq_next) { in readipv4()
389 *pkt = ipr->ip_pkt; in readipv4()
390 ipr->ip_pkt = NULL; /* Avoid free from ip_reasm_free() */ in readipv4()
394 while ((ipr = STAILQ_FIRST(&ire_list)) != NULL) { in readipv4()
396 ip_reasm_free(ipr); in readipv4()