Lines Matching refs:pData
92 static void icmp_cache_clean(PNATState pData, int iEntries);
95 icmp_init(PNATState pData, int iIcmpCacheLimit)
97 pData->icmp_socket.so_type = IPPROTO_ICMP;
98 pData->icmp_socket.so_state = SS_ISFCONNECTED;
106 pData->iIcmpCacheLimit = iIcmpCacheLimit;
108 pData->icmp_socket.s = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP);
110 pData->icmp_socket.s = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
112 if (pData->icmp_socket.s == -1)
121 pData->icmp_socket.s = getrawsock(AF_INET);
122 if (pData->icmp_socket.s == -1)
129 fd_nonblock(pData->icmp_socket.s);
132 LIST_INIT(&pData->icmp_msg_head);
135 if (icmpwin_init(pData) != 0)
146 icmp_finit(PNATState pData)
149 icmpwin_finit(pData);
151 icmp_cache_clean(pData, -1);
152 closesocket(pData->icmp_socket.s);
161 icmp_find_original_mbuf(PNATState pData, struct ip *ip)
187 LIST_FOREACH(icm, &pData->icmp_msg_head, im_list)
288 LIST_INSERT_HEAD(&pData->icmp_msg_head, icm, im_list);
289 pData->cIcmpCacheSize++;
290 if (pData->cIcmpCacheSize > pData->iIcmpCacheLimit)
291 icmp_cache_clean(pData, pData->iIcmpCacheLimit/2);
308 static void icmp_cache_clean(PNATState pData, int iEntries)
313 if (iEntries > pData->cIcmpCacheSize)
318 while(!LIST_EMPTY(&pData->icmp_msg_head))
320 icm = LIST_FIRST(&pData->icmp_msg_head);
331 pData->cIcmpCacheSize--;
332 m_freem(pData, icm->im_m);
340 icmp_attach(PNATState pData, struct mbuf *m)
349 LIST_INSERT_HEAD(&pData->icmp_msg_head, icm, im_list);
350 pData->cIcmpCacheSize++;
351 if (pData->cIcmpCacheSize > pData->iIcmpCacheLimit)
352 icmp_cache_clean(pData, pData->iIcmpCacheLimit/2);
361 icmp_input(PNATState pData, struct mbuf *m, int hlen)
415 m_copyback(pData, m, hlen + RT_OFFSETOF(struct icmp, icmp_type),
419 icmp_reflect(pData, m);
425 icmpwin_ping(pData, m, hlen);
435 if ((ip->ip_dst.s_addr & RT_H2N_U32(pData->netmask)) == pData->special_addr.s_addr)
438 switch (RT_N2H_U32(ip->ip_dst.s_addr) & ~pData->netmask)
464 if (pData->icmp_socket.s != -1)
473 status = setsockopt(pData->icmp_socket.s, IPPROTO_IP, IP_TTL,
478 rc = sendto(pData->icmp_socket.s, icp, icmplen, 0,
482 m->m_so = &pData->icmp_socket;
483 icmp_attach(pData, m);
495 icmp_error(pData, m, ICMP_UNREACH, ICMP_UNREACH_NET, 0, strerror(errno));
519 m_freem(pData, m);
550 void icmp_error(PNATState pData, struct mbuf *msrc, u_char type, u_char code, int minsize, const char *message)
602 m = m_gethdr(pData, M_NOWAIT, MT_HEADER);
653 (void) ip_output0(pData, (struct socket *)NULL, m, 1);
658 m_freem(pData, msrc);
668 m_freem(pData, msrc);
686 icmp_reflect(PNATState pData, struct mbuf *m)
707 (void) ip_output(pData, (struct socket *)NULL, m);