Home | History | Annotate | Download | only in slirp

Lines Matching defs:ip

51 static struct ip *ip_reass(register struct ip *ip,
59 * IP initialization: fill in IP protocol switch table.
60 * All protocols not implemented in kernel go to raw IP protocol handler.
72 * Ip input routine. Checksum and byte swap header. If fragmented
78 register struct ip *ip;
87 if (m->m_len < sizeof (struct ip)) {
92 ip = mtod(m, struct ip *);
94 if (ip->ip_v != IPVERSION) {
99 hlen = ip->ip_hl << 2;
100 if (hlen<sizeof(struct ip ) || hlen>m->m_len) {/* min header length */
105 /* keep ip header intact for ICMP reply
106 * ip->ip_sum = cksum(m, hlen);
107 * if (ip->ip_sum) {
117 NTOHS(ip->ip_len);
118 if (ip->ip_len < hlen) {
122 NTOHS(ip->ip_id);
123 NTOHS(ip->ip_off);
127 * is as at least much as the IP header would have us expect.
131 if (m->m_len < ip->ip_len) {
137 if (memcmp(&ip->ip_dst.s_addr, &special_addr, 3)) {
138 if (ip->ip_dst.s_addr == 0xffffffff && ip->ip_p != IPPROTO_UDP)
141 int host = ntohl(ip->ip_dst.s_addr) & 0xff;
157 if (m->m_len > ip->ip_len)
158 m_adj(m, ip->ip_len - m->m_len);
161 if(ip->ip_ttl==0 || ip->ip_ttl==1) {
172 /* We do no IP options */
173 /* if (hlen > sizeof (struct ip) && ip_dooptions(m))
185 if (ip->ip_off &~ IP_DF) {
194 if (ip->ip_id == fp->ipq_id &&
195 ip->ip_src.s_addr == fp->ipq_src.s_addr &&
196 ip->ip_dst.s_addr == fp->ipq_dst.s_addr &&
197 ip->ip_p == fp->ipq_p)
208 ip->ip_len -= hlen;
209 if (ip->ip_off & IP_MF)
210 ip->ip_tos |= 1;
212 ip->ip_tos &= ~1;
214 ip->ip_off <<= 3;
221 if (ip->ip_tos & 1 || ip->ip_off) {
223 ip = ip_reass(ip, fp);
224 if (ip == NULL)
227 m = dtom(ip);
233 ip->ip_len -= hlen;
239 switch (ip->ip_p) {
260 #define fragtoip(P) ((struct ip*)(((char*)(P)) + sizeof(struct qlink)))
267 static struct ip *
268 ip_reass(register struct ip *ip, register struct ipq *fp)
270 register struct mbuf *m = dtom(ip);
272 int hlen = ip->ip_hl << 2;
276 DEBUG_ARG("ip = %lx", (long)ip);
297 fp->ipq_p = ip->ip_p;
298 fp->ipq_id = ip->ip_id;
300 fp->ipq_src = ip->ip_src;
301 fp->ipq_dst = ip->ip_dst;
311 if (q->ipf_off > ip->ip_off)
321 i = pq->ipf_off + pq->ipf_len - ip->ip_off;
323 if (i >= ip->ip_len)
325 m_adj(dtom(ip), i);
326 ip->ip_off += i;
327 ip->ip_len -= i;
336 ip->ip_off + ip->ip_len > q->ipf_off) {
337 i = (ip->ip_off + ip->ip_len) - q->ipf_off;
354 ip_enq(iptofrag(ip), q->ipf_prev);
379 * Create header for new ip packet by
390 * the old buffer (in the mbuf), so we must point ip
398 /* DEBUG_ARG("ip = %lx", (long)ip);
399 * ip=(struct ipasfrag *)m->m_data; */
401 ip = fragtoip(q);
402 ip->ip_len = next;
403 ip->ip_tos &= ~1;
404 ip->ip_src = fp->ipq_src;
405 ip->ip_dst = fp->ipq_dst;
408 m->m_len += (ip->ip_hl << 2);
409 m->m_data -= (ip->ip_hl << 2);
411 return ip;
438 * Put an ip fragment on a reassembly chain.
463 * IP timer processing;
503 register struct ip *ip = mtod(m, struct ip *);
513 dst = ip->ip_dst;
514 cp = (u_char *)(ip + 1);
515 cnt = (ip->ip_hl << 2) - sizeof (struct ip);
525 code = &cp[IPOPT_OLEN] - (u_char *)ip;
546 code = &cp[IPOPT_OFFSET] - (u_char *)ip;
549 ipaddr.sin_addr = ip->ip_dst;
569 save_rte(cp, ip->ip_src);
589 ip->ip_dst = ipaddr.sin_addr;
596 forward = !IN_MULTICAST(ntohl(ip->ip_dst.s_addr));
601 code = &cp[IPOPT_OFFSET] - (u_char *)ip;
610 bcopy((caddr_t)(&ip->ip_dst), (caddr_t)&ipaddr.sin_addr,
628 code = cp - (u_char *)ip;
685 /* ip->ip_len -= ip->ip_hl << 2; XXX icmp_error adds in hdr length */
697 * Strip out IP options, at higher
707 struct ip *ip = mtod(m, struct ip *);
711 olen = (ip->ip_hl<<2) - sizeof (struct ip);
712 opts = (caddr_t)(ip + 1);
713 i = m->m_len - (sizeof (struct ip) + olen);
717 ip->ip_hl = sizeof(struct ip) >> 2;