errno_t
ether_attach_inet6(struct ifnet *ifp, protocol_family_t protocol_family)
{
#pragma unused(protocol_family)
	struct ifnet_attach_proto_param	proto;
	struct ifnet_demux_desc demux[1];
	u_short en_6native = htons(ETHERTYPE_IPV6);
	errno_t	error;

	bzero(&proto, sizeof (proto));
	demux[0].type = DLIL_DESC_ETYPE2;
	demux[0].data = &en_6native;
	demux[0].datalen = sizeof (en_6native);
	proto.demux_list = demux;
	proto.demux_count = 1;
	proto.input = ether_inet6_input;
	proto.pre_output = ether_inet6_pre_output;
	proto.ioctl = ether_inet6_prmod_ioctl;
	proto.resolve = ether_inet6_resolve_multi;
	error = ifnet_attach_protocol(ifp, protocol_family, &proto);
	if (error && error != EEXIST) {
		printf("WARNING: %s can't attach ipv6 to %s\n", __func__,
		    if_name(ifp));
	}

	return (error);
}
Example #2
0
File: ppp_ip.c Project: Deanzou/ppp
/* -----------------------------------------------------------------------------
attach the PPPx interface ifp to the network protocol IP,
called when the ppp interface is ready for ppp traffic
----------------------------------------------------------------------------- */
errno_t ppp_ip_attach(ifnet_t ifp, protocol_family_t protocol)
{
    int					ret;
    struct ifnet_attach_proto_param   reg;
    struct ppp_if		*wan = (struct ppp_if *)ifnet_softc(ifp);
    
    LOGDBG(ifp, ("ppp_ip_attach: name = %s, unit = %d\n", ifnet_name(ifp), ifnet_unit(ifp)));

    if (wan->ip_attached) 
        return 0;	// already attached

    bzero(&reg, sizeof(struct ifnet_attach_proto_param));
	
	reg.input = ppp_ip_input;
	reg.pre_output = ppp_ip_preoutput;
	reg.ioctl = ppp_ip_ioctl;
	ret = ifnet_attach_protocol(ifp, PF_INET, &reg);
    LOGRETURN(ret, ret, "ppp_ip_attach: ifnet_attach_protocol error = 0x%x\n");
	
    LOGDBG(ifp, ("ppp_i6_attach: ifnet_attach_protocol family = 0x%x\n", protocol));
	ifnet_find_by_name("lo0", &wan->lo_ifp);
	wan->ip_attached = 1;
	
    return 0;
}
Example #3
0
static errno_t
ipsec_attach_proto(ifnet_t				interface,
				   protocol_family_t	protocol)
{
	struct ifnet_attach_proto_param	proto;
	errno_t							result;
	
	bzero(&proto, sizeof(proto));
	proto.input = ipsec_proto_input;
	proto.pre_output = ipsec_proto_pre_output;
	
	result = ifnet_attach_protocol(interface, protocol, &proto);
	if (result != 0 && result != EEXIST) {
		printf("ipsec_attach_inet - ifnet_attach_protocol %d failed: %d\n",
			   protocol, result);
	}
	
	return result;
}
Example #4
0
errno_t
tun_inet6_attach(ifnet_t ifp, protocol_family_t proto)
{
	struct ifnet_attach_proto_param pr;
	struct ifnet_demux_desc ddesc[1];

	/* fill out pr and attach the protocol */
	ddesc[0].type = AF_INET6;
	ddesc[0].data = NULL;
	ddesc[0].datalen = 0;
	pr.demux_array = ddesc;
	pr.demux_count = 1;
	pr.input = tun_inet6_input;
	pr.pre_output = tun_inet6_pre_output;
	pr.event = NULL;
	pr.ioctl = NULL;
	pr.detached = NULL;
	pr.resolve = NULL;
	pr.send_arp = NULL;

	return ifnet_attach_protocol(ifp, proto, &pr);
}
////////////////////////////////////////////////////////////////////////////////
//
// firewire_attach_inet
//
//   IN:	ifnet_t ifp
//   
// Invoked by:
//  firewire_attach_inet will be invoked from IOFWInterface::attachToDataLinkLayer
//
////////////////////////////////////////////////////////////////////////////////
int
firewire_attach_inet(ifnet_t ifp, protocol_family_t protocol_family)
{
	struct ifnet_attach_proto_param	proto;
	struct ifnet_demux_desc demux[2];
    u_short en_native=htons(FWTYPE_IP);
    u_short arp_native=htons(FWTYPE_ARP);
	errno_t	error;
	
	bzero(&demux[0], sizeof(demux));
	demux[0].type	= DLIL_DESC_ETYPE2;
	demux[0].data	= &en_native;
	demux[0].datalen = sizeof(en_native);
	demux[1].type	= DLIL_DESC_ETYPE2;
	demux[1].data	= &arp_native;
	demux[1].datalen = sizeof(arp_native);
	
	bzero(&proto, sizeof(proto));
	proto.demux_list	= demux;
	proto.demux_count	= sizeof(demux) / sizeof(demux[0]);
	proto.input			= inet_firewire_input;
	proto.pre_output	= inet_firewire_pre_output;
	proto.ioctl			= firewire_inet_prmod_ioctl;
	proto.event			= firewire_inet_event;
	proto.resolve		= firewire_inet_resolve_multi;
	proto.send_arp		= firewire_inet_arp;
	
	error = ifnet_attach_protocol(ifp, protocol_family, &proto);
	if (error && error != EEXIST) 
	{
		printf("WARNING: firewire_attach_inet can't attach ip to %s%d\n",
			   ifnet_name(ifp), ifnet_unit(ifp));
	}
	
	return error;
}