003 File Manager
Current Path:
/usr/src/sys/net
usr
/
src
/
sys
/
net
/
📁
..
📁
altq
📄
bpf.c
(69.94 KB)
📄
bpf.h
(14.6 KB)
📄
bpf_buffer.c
(6.39 KB)
📄
bpf_buffer.h
(2.04 KB)
📄
bpf_filter.c
(12.09 KB)
📄
bpf_jitter.c
(3.43 KB)
📄
bpf_jitter.h
(3.3 KB)
📄
bpf_zerocopy.c
(16.12 KB)
📄
bpf_zerocopy.h
(2.36 KB)
📄
bpfdesc.h
(6.04 KB)
📄
bridgestp.c
(55.53 KB)
📄
bridgestp.h
(13.06 KB)
📄
debugnet.c
(26.35 KB)
📄
debugnet.h
(8.54 KB)
📄
debugnet_inet.c
(12.67 KB)
📄
debugnet_int.h
(3.11 KB)
📄
dlt.h
(44.23 KB)
📄
ethernet.h
(22.17 KB)
📄
firewire.h
(3.95 KB)
📄
ieee8023ad_lacp.c
(53.91 KB)
📄
ieee8023ad_lacp.h
(9.22 KB)
📄
ieee_oui.h
(3.64 KB)
📄
if.c
(105.86 KB)
📄
if.h
(22.3 KB)
📄
if_arp.h
(5.41 KB)
📄
if_bridge.c
(89.97 KB)
📄
if_bridgevar.h
(11.54 KB)
📄
if_clone.c
(17.42 KB)
📄
if_clone.h
(3.38 KB)
📄
if_dead.c
(3.83 KB)
📄
if_debug.c
(4.02 KB)
📄
if_disc.c
(5.95 KB)
📄
if_dl.h
(3.56 KB)
📄
if_edsc.c
(9.93 KB)
📄
if_enc.c
(12.02 KB)
📄
if_enc.h
(1.65 KB)
📄
if_epair.c
(27.75 KB)
📄
if_ethersubr.c
(37.23 KB)
📄
if_fwsubr.c
(19.22 KB)
📄
if_gif.c
(16.66 KB)
📄
if_gif.h
(4.16 KB)
📄
if_gre.c
(18.8 KB)
📄
if_gre.h
(5.69 KB)
📄
if_infiniband.c
(14.99 KB)
📄
if_ipsec.c
(24.98 KB)
📄
if_ipsec.h
(1.62 KB)
📄
if_lagg.c
(62.68 KB)
📄
if_lagg.h
(8.94 KB)
📄
if_llatbl.c
(20.5 KB)
📄
if_llatbl.h
(9.52 KB)
📄
if_llc.h
(4.53 KB)
📄
if_loop.c
(10.62 KB)
📄
if_me.c
(16.73 KB)
📄
if_media.c
(12.81 KB)
📄
if_media.h
(36.45 KB)
📄
if_mib.c
(4.6 KB)
📄
if_mib.h
(5.58 KB)
📄
if_pflog.h
(2.24 KB)
📄
if_pfsync.h
(6.85 KB)
📄
if_sppp.h
(8.37 KB)
📄
if_spppfr.c
(15.11 KB)
📄
if_spppsubr.c
(132.44 KB)
📄
if_stf.c
(19.3 KB)
📄
if_tap.h
(2.54 KB)
📄
if_tun.h
(1.43 KB)
📄
if_tuntap.c
(47.67 KB)
📄
if_types.h
(12.2 KB)
📄
if_var.h
(29.92 KB)
📄
if_vlan.c
(53.04 KB)
📄
if_vlan_var.h
(6.1 KB)
📄
if_vxlan.c
(88.14 KB)
📄
if_vxlan.h
(4.71 KB)
📄
ifdi_if.m
(8.4 KB)
📄
iflib.c
(185.91 KB)
📄
iflib.h
(14.41 KB)
📄
iflib_clone.c
(7.37 KB)
📄
iflib_private.h
(2.31 KB)
📄
ifq.h
(12.2 KB)
📄
infiniband.h
(2.64 KB)
📄
mp_ring.c
(13.3 KB)
📄
mp_ring.h
(2.77 KB)
📄
mppc.h
(2.37 KB)
📄
mppcc.c
(8.88 KB)
📄
mppcd.c
(7.89 KB)
📄
netisr.c
(44.33 KB)
📄
netisr.h
(9.31 KB)
📄
netisr_internal.h
(4.77 KB)
📄
netmap.h
(32.93 KB)
📄
netmap_legacy.h
(9.49 KB)
📄
netmap_user.h
(30.33 KB)
📄
netmap_virt.h
(3.89 KB)
📄
paravirt.h
(6.91 KB)
📄
pfil.c
(16.83 KB)
📄
pfil.h
(5.86 KB)
📄
pfkeyv2.h
(14.54 KB)
📄
pfvar.h
(48.83 KB)
📄
ppp_defs.h
(5.41 KB)
📄
radix.c
(30.87 KB)
📄
radix.h
(6.83 KB)
📄
raw_cb.c
(3.77 KB)
📄
raw_cb.h
(3.04 KB)
📄
raw_usrreq.c
(6.26 KB)
📄
rndis.h
(10.74 KB)
📁
route
📄
route.c
(19.25 KB)
📄
route.h
(16.54 KB)
📄
rss_config.c
(14.12 KB)
📄
rss_config.h
(4.69 KB)
📄
rtsock.c
(62.94 KB)
📄
sff8436.h
(8.3 KB)
📄
sff8472.h
(18.95 KB)
📄
slcompress.c
(16.25 KB)
📄
slcompress.h
(6.4 KB)
📄
toeplitz.c
(1.96 KB)
📄
toeplitz.h
(1.72 KB)
📄
vnet.c
(22.42 KB)
📄
vnet.h
(14.62 KB)
Editing: if_edsc.c
/*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following edsclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following edsclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE EDSCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * From: @(#)if_loop.c 8.1 (Berkeley) 6/10/93 * $FreeBSD$ */ /* * Discard interface driver for protocol testing and timing. * Mimics an Ethernet device so that VLANs can be attached to it etc. */ #include <sys/param.h> /* types, important constants */ #include <sys/kernel.h> /* SYSINIT for load-time initializations */ #include <sys/malloc.h> /* malloc(9) */ #include <sys/module.h> /* module(9) */ #include <sys/mbuf.h> /* mbuf(9) */ #include <sys/socket.h> /* struct ifreq */ #include <sys/sockio.h> /* socket ioctl's */ /* #include <sys/systm.h> if you need printf(9) or other all-purpose globals */ #include <net/bpf.h> /* bpf(9) */ #include <net/ethernet.h> /* Ethernet related constants and types */ #include <net/if.h> #include <net/if_var.h> /* basic part of ifnet(9) */ #include <net/if_clone.h> /* network interface cloning */ #include <net/if_types.h> /* IFT_ETHER and friends */ #include <net/if_var.h> /* kernel-only part of ifnet(9) */ #include <net/vnet.h> static const char edscname[] = "edsc"; /* * Software configuration of an interface specific to this device type. */ struct edsc_softc { struct ifnet *sc_ifp; /* ptr to generic interface configuration */ /* * A non-null driver can keep various things here, for instance, * the hardware revision, cached values of write-only registers, etc. */ }; /* * Attach to the interface cloning framework. */ VNET_DEFINE_STATIC(struct if_clone *, edsc_cloner); #define V_edsc_cloner VNET(edsc_cloner) static int edsc_clone_create(struct if_clone *, int, caddr_t); static void edsc_clone_destroy(struct ifnet *); /* * Interface driver methods. */ static void edsc_init(void *dummy); /* static void edsc_input(struct ifnet *ifp, struct mbuf *m); would be here */ static int edsc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data); static void edsc_start(struct ifnet *ifp); /* * We'll allocate softc instances from this. */ static MALLOC_DEFINE(M_EDSC, edscname, "Ethernet discard interface"); /* * Create an interface instance. */ static int edsc_clone_create(struct if_clone *ifc, int unit, caddr_t params) { struct edsc_softc *sc; struct ifnet *ifp; struct ether_addr eaddr; /* * Allocate soft and ifnet structures. Link each to the other. */ sc = malloc(sizeof(struct edsc_softc), M_EDSC, M_WAITOK | M_ZERO); ifp = sc->sc_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { free(sc, M_EDSC); return (ENOSPC); } ifp->if_softc = sc; /* * Get a name for this particular interface in its ifnet structure. */ if_initname(ifp, edscname, unit); /* * Typical Ethernet interface flags: we can do broadcast and * multicast but can't hear our own broadcasts or multicasts. */ ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST | IFF_SIMPLEX; /* * We can pretent we have the whole set of hardware features * because we just discard all packets we get from the upper layer. * However, the features are disabled initially. They can be * enabled via edsc_ioctl() when needed. */ ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_VLAN_HWTAGGING | IFCAP_VLAN_HWCSUM | IFCAP_HWCSUM | IFCAP_TSO | IFCAP_JUMBO_MTU; ifp->if_capenable = 0; /* * Set the interface driver methods. */ ifp->if_init = edsc_init; /* ifp->if_input = edsc_input; */ ifp->if_ioctl = edsc_ioctl; ifp->if_start = edsc_start; /* * Set the maximum output queue length from the global parameter. */ ifp->if_snd.ifq_maxlen = ifqmaxlen; /* * Generate an arbitrary MAC address for the cloned interface. */ ether_gen_addr(ifp, &eaddr); /* * Do ifnet initializations common to all Ethernet drivers * and attach to the network interface framework. */ ether_ifattach(ifp, eaddr.octet); /* * Now we can mark the interface as running, i.e., ready * for operation. */ ifp->if_drv_flags |= IFF_DRV_RUNNING; return (0); } /* * Destroy an interface instance. */ static void edsc_clone_destroy(struct ifnet *ifp) { struct edsc_softc *sc = ifp->if_softc; /* * Detach from the network interface framework. */ ether_ifdetach(ifp); /* * Free memory occupied by ifnet and softc. */ if_free(ifp); free(sc, M_EDSC); } /* * This method is invoked from ether_ioctl() when it's time * to bring up the hardware. */ static void edsc_init(void *dummy) { #if 0 /* what a hardware driver would do here... */ struct edsc_soft *sc = (struct edsc_softc *)dummy; struct ifnet *ifp = sc->sc_ifp; /* blah-blah-blah */ #endif } /* * Network interfaces are controlled via the ioctl(2) syscall. */ static int edsc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) { struct ifreq *ifr = (struct ifreq *)data; switch (cmd) { case SIOCSIFCAP: #if 1 /* * Just turn on any capabilities requested. * The generic ifioctl() function has already made sure * that they are supported, i.e., set in if_capabilities. */ ifp->if_capenable = ifr->ifr_reqcap; #else /* * A h/w driver would need to analyze the requested * bits and program the hardware, e.g.: */ mask = ifp->if_capenable ^ ifr->ifr_reqcap; if (mask & IFCAP_VLAN_HWTAGGING) { ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING; if (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) /* blah-blah-blah */ else /* etc-etc-etc */ } #endif break; default: /* * Offload the rest onto the common Ethernet handler. */ return (ether_ioctl(ifp, cmd, data)); } return (0); } /* * Process the output queue. */ static void edsc_start(struct ifnet *ifp) { struct mbuf *m; /* * A hardware interface driver can set IFF_DRV_OACTIVE * in ifp->if_drv_flags: * * ifp->if_drv_flags |= IFF_DRV_OACTIVE; * * to prevent if_start from being invoked again while the * transmission is under way. The flag is to protect the * device's transmitter, not the method itself. The output * queue is locked and several threads can process it in * parallel safely, so the driver can use other means to * serialize access to the transmitter. * * If using IFF_DRV_OACTIVE, the driver should clear the flag * not earlier than the current transmission is complete, e.g., * upon an interrupt from the device, not just before returning * from if_start. This method merely starts the transmission, * which may proceed asynchronously. */ /* * We loop getting packets from the queue until it's empty. * A h/w driver would loop until the device can accept more * data into its buffer, or while there are free transmit * descriptors, or whatever. */ for (;;) { /* * Try to dequeue one packet. Stop if the queue is empty. * Use IF_DEQUEUE() here if ALTQ(9) support is unneeded. */ IFQ_DEQUEUE(&ifp->if_snd, m); if (m == NULL) break; /* * Let bpf(9) at the packet. */ BPF_MTAP(ifp, m); /* * Update the interface counters. */ if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); /* * Finally, just drop the packet. * TODO: Reply to ARP requests unless IFF_NOARP is set. */ m_freem(m); } /* * ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; * would be here only if the transmission were synchronous. */ } static void vnet_edsc_init(const void *unused __unused) { /* * Connect to the network interface cloning framework. * The last argument is the number of units to be created * from the outset. It's also the minimum number of units * allowed. We don't want any units created as soon as the * driver is loaded. */ V_edsc_cloner = if_clone_simple(edscname, edsc_clone_create, edsc_clone_destroy, 0); } VNET_SYSINIT(vnet_edsc_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, vnet_edsc_init, NULL); static void vnet_edsc_uninit(const void *unused __unused) { /* * Disconnect from the cloning framework. * Existing interfaces will be disposed of properly. */ if_clone_detach(V_edsc_cloner); } VNET_SYSUNINIT(vnet_edsc_uninit, SI_SUB_INIT_IF, SI_ORDER_ANY, vnet_edsc_uninit, NULL); /* * This function provides handlers for module events, namely load and unload. */ static int edsc_modevent(module_t mod, int type, void *data) { switch (type) { case MOD_LOAD: case MOD_UNLOAD: break; default: /* * There are other event types, but we don't handle them. * See module(9). */ return (EOPNOTSUPP); } return (0); } static moduledata_t edsc_mod = { "if_edsc", /* name */ edsc_modevent, /* event handler */ NULL /* additional data */ }; DECLARE_MODULE(if_edsc, edsc_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
Upload File
Create Folder