75#include <sys/kernel.h>
76#include <sys/malloc.h>
79#include <sys/syslog.h>
80#include <sys/socket.h>
84#include <net/if_types.h>
85#include <net/if_var.h>
86#include <net/if_gif.h>
94#define IFP2NG(ifp) ((struct ng_node *)((struct gif_softc *)(ifp->if_softc))->gif_netgraph)
95#define IFP2NG_SET(ifp, val) (((struct gif_softc *)(ifp->if_softc))->gif_netgraph = (val))
231 KASSERT(!
IFP2NG(ifp), (
"%s: node already exists?", __func__));
233 log(LOG_ERR,
"%s: can't %s for %s\n",
234 __func__,
"create node", ifp->if_xname);
239 priv = malloc(
sizeof(*
priv), M_NETGRAPH, M_NOWAIT | M_ZERO);
241 log(LOG_ERR,
"%s: can't %s for %s\n",
242 __func__,
"allocate memory", ifp->if_xname);
252 log(LOG_WARNING,
"%s: can't name node %s\n",
253 __func__, ifp->if_xname);
288 struct mbuf *m = *mp;
292 tmp_af = (sa_family_t) af;
308 M_PREPEND(m,
sizeof (tmp_af), M_NOWAIT);
318 *mtod(m, sa_family_t *) = tmp_af;
320 bcopy((caddr_t)&tmp_af, mtod(m, sa_family_t *),
sizeof(tmp_af));
349 u_char orphan =
priv->lowerOrphan;
367 if (*hookptr != NULL)
372 priv->lowerOrphan = orphan;
409 strlcpy(resp->
data,
priv->ifp->if_xname, IFNAMSIZ);
417 *((u_int32_t *)resp->
data) =
priv->ifp->if_index;
448 panic(
"%s: weird hook", __func__);
460 bzero(&dst,
sizeof(dst));
463 if (m->m_pkthdr.len <
sizeof(sa_family_t)) {
467 if (m->m_len <
sizeof(sa_family_t)
468 && (m = m_pullup(m,
sizeof(sa_family_t))) == NULL) {
472 dst.sa_family = *mtod(m, sa_family_t *);
473 m_adj(m,
sizeof(sa_family_t));
481 return gif_output(
priv->ifp, m, &dst, NULL);
501 free(
priv, M_NETGRAPH);
519 priv->lowerOrphan = 0;
521 panic(
"%s: weird hook", __func__);
539 VNET_ITERATOR_DECL(vnet_iter);
547 if (ng_gif_attach_p != NULL) {
559 VNET_FOREACH(vnet_iter) {
560 CURVNET_SET_QUIET(vnet_iter);
561 CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) {
562 if (ifp->if_type == IFT_GIF)
584 ng_gif_attach_p = NULL;
585 ng_gif_detach_p = NULL;
586 ng_gif_input_p = NULL;
587 ng_gif_input_orphan_p = NULL;
int ng_connect_t(hook_p hook)
#define NG_HOOK_NODE(hook)
int ng_rcvmsg_t(node_p node, item_p item, hook_p lasthook)
int ng_disconnect_t(hook_p hook)
#define NG_NODE_SET_PRIVATE(node, val)
#define NG_RESPOND_MSG(error, here, item, resp)
#define NG_NODE_IS_VALID(node)
#define NG_HOOK_PEER(hook)
#define NG_NODE_UNREF(node)
int ng_rmnode_self(node_p here)
#define NG_SEND_DATA_ONLY(error, hook, m)
#define NG_NODE_REVIVE(node)
#define NG_HOOK_FORCE_QUEUE(hook)
int ng_rcvdata_t(hook_p hook, item_p item)
#define NG_NODE_REALLY_DIE(node)
int ng_shutdown_t(node_p node)
#define NG_FREE_ITEM(item)
int ng_make_node_common(struct ng_type *typep, node_p *nodep)
int ng_name_node(node_p node, const char *name)
int ng_constructor_t(node_p node)
#define NG_NODE_NUMHOOKS(node)
#define NGI_GET_MSG(i, m)
#define NG_NODE_PRIVATE(node)
int ng_newhook_t(node_p node, hook_p hook, const char *name)
static int ng_gif_mod_event(module_t mod, int event, void *data)
static struct ng_type ng_gif_typestruct
#define IFP2NG_SET(ifp, val)
static ng_newhook_t ng_gif_newhook
static ng_shutdown_t ng_gif_shutdown
static int ng_gif_rcv_lower(node_p node, struct mbuf *m)
static ng_connect_t ng_gif_connect
static ng_disconnect_t ng_gif_disconnect
NETGRAPH_INIT(gif, &ng_gif_typestruct)
static void ng_gif_attach(struct ifnet *ifp)
static void ng_gif_input_orphan(struct ifnet *ifp, struct mbuf *m, int af)
static int ng_gif_glue_af(struct mbuf **mp, int af)
MODULE_DEPEND(ng_gif, if_gif, 1, 1, 1)
static ng_rcvmsg_t ng_gif_rcvmsg
static ng_constructor_t ng_gif_constructor
static void ng_gif_input(struct ifnet *ifp, struct mbuf **mp, int af)
static ng_rcvdata_t ng_gif_rcvdata
static const struct ng_cmdlist ng_gif_cmdlist[]
static void ng_gif_input2(node_p node, struct mbuf **mp, int af)
static void ng_gif_detach(struct ifnet *ifp)
#define NG_GIF_HOOK_DIVERT
#define NG_GIF_HOOK_LOWER
#define NG_GIF_HOOK_ORPHAN
#define NG_MKRESPONSE(rsp, msg, len, how)
const struct ng_parse_type ng_parse_int32_type
const struct ng_parse_type ng_parse_string_type
struct ng_mesg::ng_msghdr header