- struct inpcb *inp;
- int error;
-
- inp = sotoinpcb(so);
- if (inp)
- panic("icmp6_dgram_attach");
-
- if (proto != IPPROTO_ICMPV6)
- return EINVAL;
-
- error = soreserve(so, rip_sendspace, rip_recvspace);
- if (error)
- return error;
- error = in_pcballoc(so, &ripcbinfo, p);
- if (error)
- return error;
- inp = (struct inpcb *)so->so_pcb;
- inp->inp_vflag |= INP_IPV6;
- inp->in6p_ip6_nxt = IPPROTO_ICMPV6;
- inp->in6p_hops = -1; /* use kernel default */
- inp->in6p_cksum = -1;
- MALLOC(inp->in6p_icmp6filt, struct icmp6_filter *,
- sizeof(struct icmp6_filter), M_PCB, M_WAITOK);
- if (inp->in6p_icmp6filt == NULL)
- return (ENOMEM);
- ICMP6_FILTER_SETPASSALL(inp->in6p_icmp6filt);
- return 0;
-}
-
-
-
-#ifndef HAVE_PPSRATECHECK
-#ifndef timersub
-#define timersub(tvp, uvp, vvp) \
- do { \
- (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
- (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
- if ((vvp)->tv_usec < 0) { \
- (vvp)->tv_sec--; \
- (vvp)->tv_usec += 1000000; \
- } \
- } while (0)
-#endif
-
-/*
- * ppsratecheck(): packets (or events) per second limitation.
- */
-static int
-ppsratecheck(lasttime, curpps, maxpps)
- struct timeval *lasttime;
- int *curpps;
- int maxpps; /* maximum pps allowed */
-{
- struct timeval tv, delta;
- int rv;
-
- microtime(&tv);