summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/net/if_clone.h
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd/sys/net/if_clone.h')
-rw-r--r--freebsd/sys/net/if_clone.h95
1 files changed, 29 insertions, 66 deletions
diff --git a/freebsd/sys/net/if_clone.h b/freebsd/sys/net/if_clone.h
index f125f8b5..3a60b0a1 100644
--- a/freebsd/sys/net/if_clone.h
+++ b/freebsd/sys/net/if_clone.h
@@ -35,82 +35,45 @@
#ifdef _KERNEL
-#define IFC_CLONE_INITIALIZER(name, data, maxunit, \
- attach, match, create, destroy) \
- { { 0 }, name, maxunit, NULL, 0, data, attach, match, create, destroy }
-
-/*
- * Structure describing a `cloning' interface.
- *
- * List of locks
- * (c) const until freeing
- * (d) driver specific data, may need external protection.
- * (e) locked by if_cloners_mtx
- * (i) locked by ifc_mtx mtx
- */
-struct if_clone {
- LIST_ENTRY(if_clone) ifc_list; /* (e) On list of cloners */
- const char *ifc_name; /* (c) Name of device, e.g. `gif' */
- int ifc_maxunit; /* (c) Maximum unit number */
- unsigned char *ifc_units; /* (i) Bitmap to handle units. */
- /* Considered private, access */
- /* via ifc_(alloc|free)_unit(). */
- int ifc_bmlen; /* (c) Bitmap length. */
- void *ifc_data; /* (*) Data for ifc_* functions. */
-
- /* (c) Driver specific cloning functions. Called with no locks held. */
- void (*ifc_attach)(struct if_clone *);
- int (*ifc_match)(struct if_clone *, const char *);
- int (*ifc_create)(struct if_clone *, char *, size_t, caddr_t);
- int (*ifc_destroy)(struct if_clone *, struct ifnet *);
-
- long ifc_refcnt; /* (i) Refrence count. */
- struct mtx ifc_mtx; /* Muted to protect members. */
- LIST_HEAD(, ifnet) ifc_iflist; /* (i) List of cloned interfaces */
-};
-
-void if_clone_init(void);
-void if_clone_attach(struct if_clone *);
+struct if_clone;
+
+/* Methods. */
+typedef int ifc_match_t(struct if_clone *, const char *);
+typedef int ifc_create_t(struct if_clone *, char *, size_t, caddr_t);
+typedef int ifc_destroy_t(struct if_clone *, struct ifnet *);
+
+typedef int ifcs_create_t(struct if_clone *, int, caddr_t);
+typedef void ifcs_destroy_t(struct ifnet *);
+
+/* Interface cloner (de)allocating functions. */
+struct if_clone *
+ if_clone_advanced(const char *, u_int, ifc_match_t, ifc_create_t,
+ ifc_destroy_t);
+struct if_clone *
+ if_clone_simple(const char *, ifcs_create_t, ifcs_destroy_t, u_int);
void if_clone_detach(struct if_clone *);
-void vnet_if_clone_init(void);
-
-int if_clone_create(char *, size_t, caddr_t);
-int if_clone_destroy(const char *);
-int if_clone_destroyif(struct if_clone *, struct ifnet *);
-int if_clone_list(struct if_clonereq *);
+/* Unit (de)allocating fucntions. */
int ifc_name2unit(const char *name, int *unit);
int ifc_alloc_unit(struct if_clone *, int *);
void ifc_free_unit(struct if_clone *, int);
-/*
- * The ifc_simple functions, structures, and macros implement basic
- * cloning as in 5.[012].
- */
-
-struct ifc_simple_data {
- int ifcs_minifs; /* minimum number of interfaces */
-
- int (*ifcs_create)(struct if_clone *, int, caddr_t);
- void (*ifcs_destroy)(struct ifnet *);
-};
-
-/* interface clone event */
+#ifdef _SYS_EVENTHANDLER_H_
+/* Interface clone event. */
typedef void (*if_clone_event_handler_t)(void *, struct if_clone *);
EVENTHANDLER_DECLARE(if_clone_event, if_clone_event_handler_t);
+#endif
-#define IFC_SIMPLE_DECLARE(name, minifs) \
-struct ifc_simple_data name##_cloner_data = \
- {minifs, name##_clone_create, name##_clone_destroy}; \
-struct if_clone name##_cloner = \
- IFC_CLONE_INITIALIZER(#name, &name##_cloner_data, IF_MAXUNIT, \
- ifc_simple_attach, ifc_simple_match, ifc_simple_create, ifc_simple_destroy)
+/* The below interfaces used only by net/if.c. */
+void vnet_if_clone_init(void);
+int if_clone_create(char *, size_t, caddr_t);
+int if_clone_destroy(const char *);
+int if_clone_list(struct if_clonereq *);
+struct if_clone *if_clone_findifc(struct ifnet *);
+void if_clone_addgroup(struct ifnet *, struct if_clone *);
-void ifc_simple_attach(struct if_clone *);
-int ifc_simple_match(struct if_clone *, const char *);
-int ifc_simple_create(struct if_clone *, char *, size_t, caddr_t);
-int ifc_simple_destroy(struct if_clone *, struct ifnet *);
+/* The below interface used only by epair(4). */
+int if_clone_destroyif(struct if_clone *, struct ifnet *);
#endif /* _KERNEL */
-
#endif /* !_NET_IF_CLONE_H_ */