/* ----------------------------------------------------------------------------- called from dlil when a packet from the interface is to be dispatched to the specific network protocol attached by dl_tag. the network protocol has been determined earlier by the demux function. the packet is in the mbuf chain m without the frame header, which is provided separately. (not used) ----------------------------------------------------------------------------- */ errno_t ppp_ipv6_input(ifnet_t ifp, protocol_family_t protocol, mbuf_t packet, char* header) { LOGMBUF("ppp_ipv6_input", packet); if (proto_input(PF_INET6, packet)) mbuf_freem(packet); return 0; }
/* * Process a received Ethernet packet; * the packet is in the mbuf chain m without * the ether header, which is provided separately. */ static errno_t ether_inet6_input(ifnet_t ifp, protocol_family_t protocol, mbuf_t packet, char *header) { #pragma unused(ifp, protocol) struct ether_header *eh = (struct ether_header *)(void *)header; u_int16_t ether_type; bcopy(&eh->ether_type, ðer_type, sizeof (ether_type)); if (ether_type == htons(ETHERTYPE_IPV6)) { struct ifnet *mifp; /* * Trust the ifp in the mbuf, rather than ifproto's * since the packet could have been injected via * a dlil_input_packet_list() using an ifp that is * different than the one where the packet really * came from. */ mifp = mbuf_pkthdr_rcvif(packet); /* Update L2 reachability record, if present (and not bcast) */ if (bcmp(eh->ether_shost, etherbroadcastaddr, ETHER_ADDR_LEN) != 0) { nd6_llreach_set_reachable(mifp, eh->ether_shost, ETHER_ADDR_LEN); } /* Save the Ethernet source address for all-nodes multicasts */ if (!bcmp(eh->ether_dhost, etherip6allnodes, ETHER_ADDR_LEN)) { struct ip6aux *ip6a; ip6a = ip6_addaux(packet); if (ip6a) { ip6a->ip6a_flags |= IP6A_HASEEN; bcopy(eh->ether_shost, ip6a->ip6a_ehsrc, ETHER_ADDR_LEN); } } if (proto_input(protocol, packet) != 0) m_freem(packet); } else { m_freem(packet); } return (EJUSTRETURN); }
static errno_t utun_proto_input( __unused ifnet_t interface, protocol_family_t protocol, mbuf_t m, __unused char *frame_header) { // remove protocol family first mbuf_adj(m, sizeof(u_int32_t)); if (proto_input(protocol, m) != 0) m_freem(m); return 0; }
static errno_t utun_proto_input( ifnet_t interface, protocol_family_t protocol, mbuf_t m, __unused char *frame_header) { // remove protocol family first struct utun_pcb *pcb = ifnet_softc(interface); mbuf_adj(m, UTUN_HEADER_SIZE(pcb)); if (proto_input(protocol, m) != 0) { m_freem(m); } return 0; }
//////////////////////////////////////////////////////////////////////////////// // // inet_firewire_input // // IN: struct mbuf *m, char *frame_header, ifnet_t ifp, // IN: u_long dl_tag, int sync_ok // // Invoked by : // It will be called from the context of dlil_input_thread queue from // dlil_input_packet // // Process a received firewire ARP/IP packet, the packet is in the mbuf // chain m // //////////////////////////////////////////////////////////////////////////////// static errno_t inet_firewire_input( __unused ifnet_t ifp, __unused protocol_family_t protocol_family, mbuf_t m, char *frame_header) { struct firewire_header *eh = (struct firewire_header *)frame_header; u_short fw_type; ifnet_touch_lastchange(ifp); fw_type = ntohs(eh->fw_type); switch (fw_type) { case FWTYPE_IP: { mbuf_pullup(&m, sizeof(struct ip)); if (m == NULL) return EJUSTRETURN; errno_t ret = proto_input(PF_INET, m); if( ret ) mbuf_freem(m); return ret; } case FWTYPE_ARP: firewire_arpintr(m); break; default: return ENOENT; } return 0; }
static errno_t ipsec_proto_input(ifnet_t interface, protocol_family_t protocol, mbuf_t m, __unused char *frame_header) { struct ip *ip; uint32_t af = 0; ip = mtod(m, struct ip *); if (ip->ip_v == 4) af = AF_INET; else if (ip->ip_v == 6) af = AF_INET6; mbuf_pkthdr_setrcvif(m, interface); bpf_tap_in(interface, DLT_NULL, m, &af, sizeof(af)); if (proto_input(protocol, m) != 0) m_freem(m); return 0; }
static errno_t tun_inet6_input(ifnet_t ifp, protocol_family_t protocol, mbuf_t m, char *header) { /* input the packet */ return proto_input(PF_INET6, m); }