Whitespace cleanup.
This commit is contained in:
parent
729c09bf00
commit
22d3fb1917
@ -56,15 +56,15 @@ LIST_HEAD(handler_chain, proto_handler) handler_chain = LIST_HEAD_INITIALIZER(ha
|
|||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
struct rwlock handler_rw;
|
struct rwlock handler_rw;
|
||||||
#endif
|
#endif
|
||||||
SLIST_HEAD(dll_chain, dll) dll_chain = SLIST_HEAD_INITIALIZER(dll_chain);
|
SLIST_HEAD(dll_chain, dll) dll_chain = SLIST_HEAD_INITIALIZER(dll_chain);
|
||||||
|
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
|
|
||||||
#define LIBALIAS_RWLOCK_INIT() \
|
#define LIBALIAS_RWLOCK_INIT() \
|
||||||
rw_init(&handler_rw, "Libalias_modules_rwlock")
|
rw_init(&handler_rw, "Libalias_modules_rwlock")
|
||||||
#define LIBALIAS_RWLOCK_DESTROY() rw_destroy(&handler_rw)
|
#define LIBALIAS_RWLOCK_DESTROY() rw_destroy(&handler_rw)
|
||||||
#define LIBALIAS_WLOCK_ASSERT() \
|
#define LIBALIAS_WLOCK_ASSERT() \
|
||||||
rw_assert(&handler_rw, RA_WLOCKED)
|
rw_assert(&handler_rw, RA_WLOCKED)
|
||||||
|
|
||||||
static __inline void
|
static __inline void
|
||||||
LIBALIAS_RLOCK(void)
|
LIBALIAS_RLOCK(void)
|
||||||
@ -116,7 +116,7 @@ _handler_chain_destroy(void)
|
|||||||
#define LIBALIAS_WUNLOCK() ;
|
#define LIBALIAS_WUNLOCK() ;
|
||||||
#define _handler_chain_init() ;
|
#define _handler_chain_init() ;
|
||||||
#define _handler_chain_destroy() ;
|
#define _handler_chain_destroy() ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
handler_chain_init(void)
|
handler_chain_init(void)
|
||||||
@ -138,7 +138,7 @@ _attach_handler(struct proto_handler *p)
|
|||||||
LIBALIAS_WLOCK_ASSERT();
|
LIBALIAS_WLOCK_ASSERT();
|
||||||
b = NULL;
|
b = NULL;
|
||||||
LIST_FOREACH(b, &handler_chain, entries) {
|
LIST_FOREACH(b, &handler_chain, entries) {
|
||||||
if ((b->pri == p->pri) &&
|
if ((b->pri == p->pri) &&
|
||||||
(b->dir == p->dir) &&
|
(b->dir == p->dir) &&
|
||||||
(b->proto == p->proto))
|
(b->proto == p->proto))
|
||||||
return (EEXIST); /* Priority conflict. */
|
return (EEXIST); /* Priority conflict. */
|
||||||
@ -160,7 +160,7 @@ _detach_handler(struct proto_handler *p)
|
|||||||
{
|
{
|
||||||
struct proto_handler *b, *b_tmp;
|
struct proto_handler *b, *b_tmp;
|
||||||
|
|
||||||
LIBALIAS_WLOCK_ASSERT();
|
LIBALIAS_WLOCK_ASSERT();
|
||||||
LIST_FOREACH_SAFE(b, &handler_chain, entries, b_tmp) {
|
LIST_FOREACH_SAFE(b, &handler_chain, entries, b_tmp) {
|
||||||
if (b == p) {
|
if (b == p) {
|
||||||
LIST_REMOVE(b, entries);
|
LIST_REMOVE(b, entries);
|
||||||
@ -178,10 +178,10 @@ LibAliasAttachHandlers(struct proto_handler *_p)
|
|||||||
LIBALIAS_WLOCK();
|
LIBALIAS_WLOCK();
|
||||||
error = -1;
|
error = -1;
|
||||||
for (i = 0; 1; i++) {
|
for (i = 0; 1; i++) {
|
||||||
if (*((int *)&_p[i]) == EOH)
|
if (*((int *)&_p[i]) == EOH)
|
||||||
break;
|
break;
|
||||||
error = _attach_handler(&_p[i]);
|
error = _attach_handler(&_p[i]);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LIBALIAS_WUNLOCK();
|
LIBALIAS_WUNLOCK();
|
||||||
@ -196,10 +196,10 @@ LibAliasDetachHandlers(struct proto_handler *_p)
|
|||||||
LIBALIAS_WLOCK();
|
LIBALIAS_WLOCK();
|
||||||
error = -1;
|
error = -1;
|
||||||
for (i = 0; 1; i++) {
|
for (i = 0; 1; i++) {
|
||||||
if (*((int *)&_p[i]) == EOH)
|
if (*((int *)&_p[i]) == EOH)
|
||||||
break;
|
break;
|
||||||
error = _detach_handler(&_p[i]);
|
error = _detach_handler(&_p[i]);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LIBALIAS_WUNLOCK();
|
LIBALIAS_WUNLOCK();
|
||||||
@ -219,7 +219,7 @@ detach_handler(struct proto_handler *_p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
find_handler(int8_t dir, int8_t proto, struct libalias *la, __unused struct ip *pip,
|
find_handler(int8_t dir, int8_t proto, struct libalias *la, __unused struct ip *pip,
|
||||||
struct alias_data *ad)
|
struct alias_data *ad)
|
||||||
{
|
{
|
||||||
struct proto_handler *p;
|
struct proto_handler *p;
|
||||||
@ -235,14 +235,14 @@ find_handler(int8_t dir, int8_t proto, struct libalias *la, __unused struct ip *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
LIBALIAS_RUNLOCK();
|
LIBALIAS_RUNLOCK();
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct proto_handler *
|
struct proto_handler *
|
||||||
first_handler(void)
|
first_handler(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
return (LIST_FIRST(&handler_chain));
|
return (LIST_FIRST(&handler_chain));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dll manipulation code - this code is not thread safe... */
|
/* Dll manipulation code - this code is not thread safe... */
|
||||||
@ -270,7 +270,7 @@ detach_dll(char *p)
|
|||||||
error = NULL;
|
error = NULL;
|
||||||
SLIST_FOREACH_SAFE(b, &dll_chain, next, b_tmp)
|
SLIST_FOREACH_SAFE(b, &dll_chain, next, b_tmp)
|
||||||
if (!strncmp(b->name, p, DLL_LEN)) {
|
if (!strncmp(b->name, p, DLL_LEN)) {
|
||||||
SLIST_REMOVE(&dll_chain, b, dll, next);
|
SLIST_REMOVE(&dll_chain, b, dll, next);
|
||||||
error = b;
|
error = b;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -45,102 +45,94 @@ MALLOC_DECLARE(M_ALIAS);
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Protocol handlers struct & function. */
|
|
||||||
|
|
||||||
/* Packet flow direction. */
|
/* Packet flow direction. */
|
||||||
#define IN 1
|
#define IN 1
|
||||||
#define OUT 2
|
#define OUT 2
|
||||||
|
|
||||||
/* Working protocol. */
|
/* Working protocol. */
|
||||||
#define IP 1
|
#define IP 1
|
||||||
#define TCP 2
|
#define TCP 2
|
||||||
#define UDP 4
|
#define UDP 4
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data passed to protocol handler module, it must be filled
|
* Data passed to protocol handler module, it must be filled
|
||||||
* right before calling find_handler() to determine which
|
* right before calling find_handler() to determine which
|
||||||
* module is elegible to be called.
|
* module is elegible to be called.
|
||||||
*/
|
*/
|
||||||
|
struct alias_data {
|
||||||
|
struct alias_link *lnk;
|
||||||
|
struct in_addr *oaddr; /* Original address. */
|
||||||
|
struct in_addr *aaddr; /* Alias address. */
|
||||||
|
uint16_t *aport; /* Alias port. */
|
||||||
|
uint16_t *sport, *dport; /* Source & destination port */
|
||||||
|
uint16_t maxpktsize; /* Max packet size. */
|
||||||
|
};
|
||||||
|
|
||||||
struct alias_data {
|
/*
|
||||||
struct alias_link *lnk;
|
|
||||||
struct in_addr *oaddr; /* Original address. */
|
|
||||||
struct in_addr *aaddr; /* Alias address. */
|
|
||||||
uint16_t *aport; /* Alias port. */
|
|
||||||
uint16_t *sport, *dport; /* Source & destination port */
|
|
||||||
uint16_t maxpktsize; /* Max packet size. */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This structure contains all the information necessary to make
|
* This structure contains all the information necessary to make
|
||||||
* a protocol handler correctly work.
|
* a protocol handler correctly work.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct proto_handler {
|
struct proto_handler {
|
||||||
u_int pri; /* Handler priority. */
|
u_int pri; /* Handler priority. */
|
||||||
int16_t dir; /* Flow direction. */
|
int16_t dir; /* Flow direction. */
|
||||||
uint8_t proto; /* Working protocol. */
|
uint8_t proto; /* Working protocol. */
|
||||||
int (*fingerprint)(struct libalias *, /* Fingerprint * function. */
|
/* Fingerprint * function. */
|
||||||
struct alias_data *);
|
int (*fingerprint)(struct libalias *, struct alias_data *);
|
||||||
int (*protohandler)(struct libalias *, /* Aliasing * function. */
|
/* Aliasing * function. */
|
||||||
struct ip *, struct alias_data *);
|
int (*protohandler)(struct libalias *, struct ip *,
|
||||||
|
struct alias_data *);
|
||||||
LIST_ENTRY(proto_handler) entries;
|
LIST_ENTRY(proto_handler) entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
/*
|
|
||||||
* Used only in userland when libalias needs to keep track of all
|
* Used only in userland when libalias needs to keep track of all
|
||||||
* module loaded. In kernel land (kld mode) we don't need to care
|
* module loaded. In kernel land (kld mode) we don't need to care
|
||||||
* care about libalias modules cause it's kld to do it for us.
|
* care about libalias modules cause it's kld to do it for us.
|
||||||
*/
|
*/
|
||||||
|
#define DLL_LEN 32
|
||||||
#define DLL_LEN 32
|
struct dll {
|
||||||
struct dll {
|
char name[DLL_LEN]; /* Name of module. */
|
||||||
char name[DLL_LEN]; /* Name of module. */
|
void *handle; /*
|
||||||
void *handle; /*
|
* Ptr to shared obj obtained through
|
||||||
* Ptr to shared obj obtained through
|
* dlopen() - use this ptr to get access
|
||||||
* dlopen() - use this ptr to get access
|
* to any symbols from a loaded module
|
||||||
* to any symbols from a loaded module
|
* via dlsym().
|
||||||
* via dlsym().
|
*/
|
||||||
*/
|
SLIST_ENTRY(dll) next;
|
||||||
SLIST_ENTRY(dll) next;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Functions used with protocol handlers. */
|
/* Functions used with protocol handlers. */
|
||||||
|
void handler_chain_init(void);
|
||||||
void handler_chain_init(void);
|
void handler_chain_destroy(void);
|
||||||
void handler_chain_destroy(void);
|
int LibAliasAttachHandlers(struct proto_handler *);
|
||||||
int LibAliasAttachHandlers(struct proto_handler *);
|
int LibAliasDetachHandlers(struct proto_handler *);
|
||||||
int LibAliasDetachHandlers(struct proto_handler *);
|
int detach_handler(struct proto_handler *);
|
||||||
int detach_handler(struct proto_handler *);
|
int find_handler(int8_t, int8_t, struct libalias *, struct ip *,
|
||||||
int find_handler(int8_t, int8_t, struct libalias *,
|
struct alias_data *);
|
||||||
struct ip *, struct alias_data *);
|
|
||||||
struct proto_handler *first_handler(void);
|
struct proto_handler *first_handler(void);
|
||||||
|
|
||||||
/* Functions used with dll module. */
|
/* Functions used with dll module. */
|
||||||
|
void dll_chain_init(void);
|
||||||
void dll_chain_init(void);
|
void dll_chain_destroy(void);
|
||||||
void dll_chain_destroy(void);
|
int attach_dll(struct dll *);
|
||||||
int attach_dll(struct dll *);
|
void *detach_dll(char *);
|
||||||
void *detach_dll(char *);
|
struct dll *walk_dll_chain(void);
|
||||||
struct dll *walk_dll_chain(void);
|
|
||||||
|
|
||||||
/* End of handlers. */
|
/* End of handlers. */
|
||||||
#define EOH -1
|
#define EOH -1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some defines borrowed from sys/module.h used to compile a kld
|
* Some defines borrowed from sys/module.h used to compile a kld
|
||||||
* in userland as a shared lib.
|
* in userland as a shared lib.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _KERNEL
|
#ifndef _KERNEL
|
||||||
typedef enum modeventtype {
|
typedef enum modeventtype {
|
||||||
MOD_LOAD,
|
MOD_LOAD,
|
||||||
MOD_UNLOAD,
|
MOD_UNLOAD,
|
||||||
MOD_SHUTDOWN,
|
MOD_SHUTDOWN,
|
||||||
MOD_QUIESCE
|
MOD_QUIESCE
|
||||||
} modeventtype_t;
|
} modeventtype_t;
|
||||||
|
|
||||||
typedef struct module *module_t;
|
typedef struct module *module_t;
|
||||||
typedef int (*modeventhand_t)(module_t, int /* modeventtype_t */, void *);
|
typedef int (*modeventhand_t)(module_t, int /* modeventtype_t */, void *);
|
||||||
|
|
||||||
@ -148,10 +140,10 @@ typedef int (*modeventhand_t)(module_t, int /* modeventtype_t */, void *);
|
|||||||
* Struct for registering modules statically via SYSINIT.
|
* Struct for registering modules statically via SYSINIT.
|
||||||
*/
|
*/
|
||||||
typedef struct moduledata {
|
typedef struct moduledata {
|
||||||
const char *name; /* module name */
|
const char *name; /* module name */
|
||||||
modeventhand_t evhand; /* event handler */
|
modeventhand_t evhand; /* event handler */
|
||||||
void *priv; /* extra data */
|
void *priv; /* extra data */
|
||||||
} moduledata_t;
|
} moduledata_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !_ALIAS_MOD_H_ */
|
#endif /* !_ALIAS_MOD_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user