Beispiel #1
0
static int
ipfw_log_clone_destroy(struct if_clone *ifc, struct ifnet *ifp)
{
	int unit;

	if (ifp == NULL)
		return (0);

	LOGIF_WLOCK();
	if (log_if != NULL && ifp == log_if)
		log_if = NULL;
	else {
		LOGIF_WUNLOCK();
		return (EINVAL);
	}
	LOGIF_WUNLOCK();

	unit = ifp->if_dunit;
	bpfdetach(ifp);
	if_detach(ifp);
	if_free(ifp);
	ifc_free_unit(ifc, unit);

	return (0);
}
Beispiel #2
0
static int
ipfwlog_clone_create(struct if_clone *ifc, int unit, caddr_t params)
{
	struct ifnet *ifp;

	ifp = if_alloc(IFT_PFLOG);
	if (ifp == NULL)
		return (ENOSPC);
	if_initname(ifp, ipfwlogname, unit);
	ifp->if_flags = IFF_UP | IFF_SIMPLEX | IFF_MULTICAST;
	ifp->if_mtu = 65536;
	ifp->if_ioctl = ipfw_bpf_ioctl;
	ifp->if_output = ipfw_bpf_output;
	ifp->if_hdrlen = PFLOG_HDRLEN;
	if_attach(ifp);
	bpfattach(ifp, DLT_PFLOG, PFLOG_HDRLEN);
	LOGIF_WLOCK();
	if (V_pflog_if != NULL) {
		LOGIF_WUNLOCK();
		bpfdetach(ifp);
		if_detach(ifp);
		if_free(ifp);
		return (EEXIST);
	}
	V_pflog_if = ifp;
	LOGIF_WUNLOCK();
	return (0);
}
Beispiel #3
0
static int
ipfw_log_clone_destroy(struct ifnet *ifp)
{
	int unit;

	if (ifp == NULL)
		return (0);

	unit = ifp->if_dunit;
	if (unit < 0 || unit >= LOG_IF_MAX) {
		return EINVAL;
	}
	if (log_if_table[unit] == NULL) {
		return EINVAL;
	}
	LOGIF_WLOCK();
	log_if_table[unit] = NULL;
	bpfdetach(ifp);
	if_detach(ifp);
	if_free(ifp);
	log_if_count--;
	LOGIF_WUNLOCK();

	return (0);
}
Beispiel #4
0
static int
ipfw_log_clone_create(struct if_clone *ifc, char *name, size_t len,
    caddr_t params)
{
	int error;
	int unit;
	struct ifnet *ifp;

	error = ifc_name2unit(name, &unit);
	if (error)
		return (error);

	error = ifc_alloc_unit(ifc, &unit);
	if (error)
		return (error);

	ifp = if_alloc(IFT_PFLOG);
	if (ifp == NULL) {
		ifc_free_unit(ifc, unit);
		return (ENOSPC);
	}
	ifp->if_dname = ipfwname;
	ifp->if_dunit = unit;
	snprintf(ifp->if_xname, IFNAMSIZ, "%s%d", ipfwname, unit);
	strlcpy(name, ifp->if_xname, len);
	ifp->if_mtu = 65536;
	ifp->if_flags = IFF_UP | IFF_SIMPLEX | IFF_MULTICAST;
	ifp->if_init = (void *)log_dummy;
	ifp->if_ioctl = log_dummy;
	ifp->if_start = ipfw_log_start;
	ifp->if_output = ipfw_log_output;
	ifp->if_addrlen = 6;
	ifp->if_hdrlen = 14;
	ifp->if_broadcastaddr = ipfwbroadcastaddr;
	ifp->if_baudrate = IF_Mbps(10);

	LOGIF_WLOCK();
	if (log_if == NULL)
		log_if = ifp;
	else {
		LOGIF_WUNLOCK();
		if_free(ifp);
		ifc_free_unit(ifc, unit);
		return (EEXIST);
	}
	LOGIF_WUNLOCK();
	if_attach(ifp);
	bpfattach(ifp, DLT_EN10MB, 14);

	return (0);
}
Beispiel #5
0
static void
ipfw_clone_destroy(struct ifnet *ifp)
{

	LOGIF_WLOCK();
	if (ifp->if_hdrlen == ETHER_HDR_LEN)
		V_log_if = NULL;
	else
		V_pflog_if = NULL;
	LOGIF_WUNLOCK();

	bpfdetach(ifp);
	if_detach(ifp);
	if_free(ifp);
}
Beispiel #6
0
static int
ipfw_log_clone_create(struct if_clone *ifc, int unit, caddr_t param __unused)
{
	struct ifnet *ifp;

	if (unit < 0 || unit >= LOG_IF_MAX) {
		return EINVAL;
	}
	if (log_if_table[unit] != NULL) {
		return EINVAL;
	}

	ifp = if_alloc(IFT_PFLOG);
	if_initname(ifp, ipfw_log_ifname, unit);
	ifq_set_maxlen(&ifp->if_snd, ifqmaxlen);
	ifq_set_ready(&ifp->if_snd);

	ifp->if_mtu = 65536;
	ifp->if_flags = IFF_UP | IFF_SIMPLEX | IFF_MULTICAST;
	ifp->if_init = (void *)log_dummy;
	ifp->if_ioctl = log_dummy;
	ifp->if_start = ipfw_log_start;
	ifp->if_output = ipfw_log_output;
	ifp->if_addrlen = 6;
	ifp->if_hdrlen = 14;
	ifp->if_broadcastaddr = ipfwbroadcastaddr;
	ifp->if_baudrate = IF_Mbps(10);

	LOGIF_WLOCK();
	log_if_table[unit] = ifp;
	log_if_count++;
	if_attach(ifp, NULL);
	bpfattach(ifp, DLT_EN10MB, ETHER_HDR_LEN);
	LOGIF_WUNLOCK();

	return (0);
}