-#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);
-
- timersub(&tv, lasttime, &delta);
-
- /*
- * Check for 0,0 so that the message will be seen at least once.
- * If more than one second has passed since the last update of
- * lasttime, reset the counter.
- *
- * we do increment *curpps even in *curpps < maxpps case, as some may
- * try to use *curpps for stat purposes as well.
- */
- if ((lasttime->tv_sec == 0 && lasttime->tv_usec == 0) ||
- delta.tv_sec >= 1) {
- *lasttime = tv;
- *curpps = 0;
- rv = 1;
- } else if (maxpps < 0)
- rv = 1;
- else if (*curpps < maxpps)
- rv = 1;
- else
- rv = 0;
-
-#if 1 /* DIAGNOSTIC? */
- /* be careful about wrap-around */
- if (*curpps + 1 > 0)
- *curpps = *curpps + 1;
-#else
- /*
- * assume that there's not too many calls to this function.
- * not sure if the assumption holds, as it depends on *caller's*
- * behavior, not the behavior of this function.
- * IMHO it is wrong to make assumption on the caller's behavior,
- * so the above #if is #if 1, not #ifdef DIAGNOSTIC.
- */
- *curpps = *curpps + 1;
-#endif
-
- return (rv);
+ 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;