| 78 | } |
| 79 | |
| 80 | void |
| 81 | raw_input_ext(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src, |
| 82 | raw_input_cb_fn cb) |
| 83 | { |
| 84 | struct rawcb *rp; |
| 85 | struct mbuf *m = m0; |
| 86 | struct socket *last; |
| 87 | |
| 88 | last = NULL; |
| 89 | mtx_lock(&rawcb_mtx); |
| 90 | LIST_FOREACH(rp, &V_rawcb_list, list) { |
| 91 | if (rp->rcb_proto.sp_family != proto->sp_family) |
| 92 | continue; |
| 93 | if (rp->rcb_proto.sp_protocol && |
| 94 | rp->rcb_proto.sp_protocol != proto->sp_protocol) |
| 95 | continue; |
| 96 | if (cb != NULL && (*cb)(m, proto, src, rp) != 0) |
| 97 | continue; |
| 98 | if (last) { |
| 99 | struct mbuf *n; |
| 100 | n = m_copym(m, 0, M_COPYALL, M_NOWAIT); |
| 101 | if (n) { |
| 102 | if (sbappendaddr(&last->so_rcv, src, |
| 103 | n, (struct mbuf *)0) == 0) |
| 104 | /* should notify about lost packet */ |
| 105 | m_freem(n); |
| 106 | else |
| 107 | sorwakeup(last); |
| 108 | } |
| 109 | } |
| 110 | last = rp->rcb_socket; |
| 111 | } |
| 112 | if (last) { |
| 113 | if (sbappendaddr(&last->so_rcv, src, |
| 114 | m, (struct mbuf *)0) == 0) |
| 115 | m_freem(m); |
| 116 | else |
| 117 | sorwakeup(last); |
| 118 | } else |
| 119 | m_freem(m); |
| 120 | mtx_unlock(&rawcb_mtx); |
| 121 | } |
| 122 | |
| 123 | /*ARGSUSED*/ |
| 124 | void |
no test coverage detected