FreeBSD kernel netgraph code
ng_sscop_cust.h File Reference
#include <sys/param.h>
#include <sys/types.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/mbuf.h>
#include <sys/queue.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <machine/stdarg.h>
#include <netnatm/saal/sscopdef.h>
Include dependency graph for ng_sscop_cust.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MEMINIT()
 
#define MEMZALLOC(PTR, CAST, SIZE)    ((PTR) = (CAST)malloc((SIZE), M_NG_SSCOP, M_NOWAIT | M_ZERO))
 
#define MEMFREE(PTR)    free((PTR), M_NG_SSCOP)
 
#define MSG_ALLOC(PTR)    MEMZALLOC(PTR, struct sscop_msg *, sizeof(struct sscop_msg))
 
#define MSG_FREE(PTR)    MEMFREE(PTR)
 
#define SIG_ALLOC(PTR)    MEMZALLOC(PTR, struct sscop_sig *, sizeof(struct sscop_sig))
 
#define SIG_FREE(PTR)    MEMFREE(PTR)
 
#define TIMER_INIT(S, T)   ng_callout_init(&(S)->t_##T)
 
#define TIMER_STOP(S, T)
 
#define TIMER_RESTART(S, T)
 
#define TIMER_ISACT(S, T)   (callout_pending(&(S)->t_##T))
 
#define TIMER_FUNC(T, N)
 
#define MSGQ_EMPTY(Q)   TAILQ_EMPTY(Q)
 
#define MSGQ_INIT(Q)   TAILQ_INIT(Q)
 
#define MSGQ_FOREACH(P, Q)   TAILQ_FOREACH(P, Q, link)
 
#define MSGQ_REMOVE(Q, M)   TAILQ_REMOVE(Q, M, link)
 
#define MSGQ_INSERT_BEFORE(B, M)   TAILQ_INSERT_BEFORE(B, M, link)
 
#define MSGQ_APPEND(Q, M)   TAILQ_INSERT_TAIL(Q, M, link)
 
#define MSGQ_PEEK(Q)   TAILQ_FIRST((Q))
 
#define MSGQ_GET(Q)   ng_sscop_msgq_get((Q))
 
#define DECL_MSGQ_GET
 
#define MSGQ_CLEAR(Q)
 
#define SIGQ_INIT(Q)   TAILQ_INIT(Q)
 
#define SIGQ_APPEND(Q, S)   TAILQ_INSERT_TAIL(Q, S, link)
 
#define SIGQ_EMPTY(Q)   TAILQ_EMPTY(Q)
 
#define SIGQ_GET(Q)   ng_sscop_sigq_get((Q))
 
#define DECL_SIGQ_GET
 
#define SIGQ_MOVE(F, T)
 
#define SIGQ_PREPEND(F, T)
 
#define SIGQ_CLEAR(Q)
 
#define MBUF_FREE(M)   do { if ((M)) m_freem((M)); } while(0)
 
#define MBUF_DUP(M)   m_copypacket((M), M_NOWAIT)
 
#define MBUF_LEN(M)   ((size_t)(M)->m_pkthdr.len)
 
#define MBUF_TRAIL32(M, I)   ng_sscop_mbuf_trail32((M), (I))
 
#define MBUF_STRIP32(M)   ng_sscop_mbuf_strip32((M))
 
#define MBUF_GET32(M)   ng_sscop_mbuf_get32((M))
 
#define MBUF_APPEND32(M, W)
 
#define MBUF_PAD4(M)   ng_sscop_mbuf_pad4((M))
 
#define MBUF_UNPAD(M, P)   do { if( (P) > 0) m_adj((M), -(P)); } while (0)
 
#define MBUF_ALLOC(N)   ng_sscop_mbuf_alloc((N))
 
#define DECL_MBUF_ALLOC
 
#define ASSERT(X)
 

Typedefs

typedef struct callout sscop_timer_t
 

Functions

typedef TAILQ_ENTRY (sscop_msg) sscop_msgq_link_t
 
typedef TAILQ_HEAD (sscop_msgq, sscop_msg) sscop_msgq_head_t
 
typedef TAILQ_ENTRY (sscop_sig) sscop_sigq_link_t
 
typedef TAILQ_HEAD (sscop_sigq, sscop_sig) sscop_sigq_head_t
 
static uint32_t __inline ng_sscop_mbuf_trail32 (const struct mbuf *m, int i)
 
static uint32_t __inline ng_sscop_mbuf_strip32 (struct mbuf *m)
 
static uint32_t __inline ng_sscop_mbuf_get32 (struct mbuf *m)
 
static u_int __inline ng_sscop_mbuf_pad4 (struct mbuf *m)
 

Macro Definition Documentation

◆ ASSERT

#define ASSERT (   X)

Definition at line 343 of file ng_sscop_cust.h.

◆ DECL_MBUF_ALLOC

#define DECL_MBUF_ALLOC
Value:
static __inline struct mbuf * \
ng_sscop_mbuf_alloc(size_t n) \
{ \
struct mbuf *m; \
\
MGETHDR(m, M_NOWAIT, MT_DATA); \
if (m != NULL) { \
m->m_len = 0; \
m->m_pkthdr.len = 0; \
if (n > MHLEN) { \
if (!(MCLGET(m, M_NOWAIT))){ \
m_free(m); \
m = NULL; \
} \
} \
} \
return (m); \
}

Definition at line 320 of file ng_sscop_cust.h.

◆ DECL_MSGQ_GET

#define DECL_MSGQ_GET
Value:
static __inline struct sscop_msg * \
ng_sscop_msgq_get(struct sscop_msgq *q) \
{ \
struct sscop_msg *m; \
\
m = TAILQ_FIRST(q); \
if (m != NULL) \
TAILQ_REMOVE(q, m, link); \
return (m); \
}

Definition at line 151 of file ng_sscop_cust.h.

◆ DECL_SIGQ_GET

#define DECL_SIGQ_GET
Value:
static __inline struct sscop_sig * \
ng_sscop_sigq_get(struct sscop_sigq *q) \
{ \
struct sscop_sig *s; \
\
s = TAILQ_FIRST(q); \
if (s != NULL) \
TAILQ_REMOVE(q, s, link); \
return (s); \
}

Definition at line 186 of file ng_sscop_cust.h.

◆ MBUF_ALLOC

#define MBUF_ALLOC (   N)    ng_sscop_mbuf_alloc((N))

Definition at line 318 of file ng_sscop_cust.h.

◆ MBUF_APPEND32

#define MBUF_APPEND32 (   M,
 
)
Value:
do { \
uint32_t _w = (W); \
\
_w = htonl(_w); \
m_copyback((M), (M)->m_pkthdr.len, 4, (caddr_t)&_w); \
} while (0)

Definition at line 287 of file ng_sscop_cust.h.

◆ MBUF_DUP

#define MBUF_DUP (   M)    m_copypacket((M), M_NOWAIT)

Definition at line 238 of file ng_sscop_cust.h.

◆ MBUF_FREE

#define MBUF_FREE (   M)    do { if ((M)) m_freem((M)); } while(0)

Definition at line 237 of file ng_sscop_cust.h.

◆ MBUF_GET32

#define MBUF_GET32 (   M)    ng_sscop_mbuf_get32((M))

Definition at line 272 of file ng_sscop_cust.h.

◆ MBUF_LEN

#define MBUF_LEN (   M)    ((size_t)(M)->m_pkthdr.len)

Definition at line 239 of file ng_sscop_cust.h.

◆ MBUF_PAD4

#define MBUF_PAD4 (   M)    ng_sscop_mbuf_pad4((M))

Definition at line 299 of file ng_sscop_cust.h.

◆ MBUF_STRIP32

#define MBUF_STRIP32 (   M)    ng_sscop_mbuf_strip32((M))

Definition at line 260 of file ng_sscop_cust.h.

◆ MBUF_TRAIL32

#define MBUF_TRAIL32 (   M,
 
)    ng_sscop_mbuf_trail32((M), (I))

Definition at line 246 of file ng_sscop_cust.h.

◆ MBUF_UNPAD

#define MBUF_UNPAD (   M,
 
)    do { if( (P) > 0) m_adj((M), -(P)); } while (0)

Definition at line 313 of file ng_sscop_cust.h.

◆ MEMFREE

#define MEMFREE (   PTR)     free((PTR), M_NG_SSCOP)

Definition at line 65 of file ng_sscop_cust.h.

◆ MEMINIT

#define MEMINIT ( )
Value:
MALLOC_DECLARE(M_NG_SSCOP); \
DECL_MSGQ_GET \
DECL_SIGQ_GET \
DECL_MBUF_ALLOC
MALLOC_DECLARE(M_NG_CCATM)

Definition at line 57 of file ng_sscop_cust.h.

◆ MEMZALLOC

#define MEMZALLOC (   PTR,
  CAST,
  SIZE 
)     ((PTR) = (CAST)malloc((SIZE), M_NG_SSCOP, M_NOWAIT | M_ZERO))

Definition at line 63 of file ng_sscop_cust.h.

◆ MSG_ALLOC

#define MSG_ALLOC (   PTR)     MEMZALLOC(PTR, struct sscop_msg *, sizeof(struct sscop_msg))

Definition at line 68 of file ng_sscop_cust.h.

◆ MSG_FREE

#define MSG_FREE (   PTR)     MEMFREE(PTR)

Definition at line 70 of file ng_sscop_cust.h.

◆ MSGQ_APPEND

#define MSGQ_APPEND (   Q,
 
)    TAILQ_INSERT_TAIL(Q, M, link)

Definition at line 146 of file ng_sscop_cust.h.

◆ MSGQ_CLEAR

#define MSGQ_CLEAR (   Q)
Value:
do { \
struct sscop_msg *_m1, *_m2; \
\
_m1 = TAILQ_FIRST(Q); \
while (_m1 != NULL) { \
_m2 = TAILQ_NEXT(_m1, link); \
SSCOP_MSG_FREE(_m1); \
_m1 = _m2; \
} \
TAILQ_INIT((Q)); \
} while (0)

Definition at line 163 of file ng_sscop_cust.h.

◆ MSGQ_EMPTY

#define MSGQ_EMPTY (   Q)    TAILQ_EMPTY(Q)

Definition at line 141 of file ng_sscop_cust.h.

◆ MSGQ_FOREACH

#define MSGQ_FOREACH (   P,
 
)    TAILQ_FOREACH(P, Q, link)

Definition at line 143 of file ng_sscop_cust.h.

◆ MSGQ_GET

#define MSGQ_GET (   Q)    ng_sscop_msgq_get((Q))

Definition at line 149 of file ng_sscop_cust.h.

◆ MSGQ_INIT

#define MSGQ_INIT (   Q)    TAILQ_INIT(Q)

Definition at line 142 of file ng_sscop_cust.h.

◆ MSGQ_INSERT_BEFORE

#define MSGQ_INSERT_BEFORE (   B,
 
)    TAILQ_INSERT_BEFORE(B, M, link)

Definition at line 145 of file ng_sscop_cust.h.

◆ MSGQ_PEEK

#define MSGQ_PEEK (   Q)    TAILQ_FIRST((Q))

Definition at line 147 of file ng_sscop_cust.h.

◆ MSGQ_REMOVE

#define MSGQ_REMOVE (   Q,
 
)    TAILQ_REMOVE(Q, M, link)

Definition at line 144 of file ng_sscop_cust.h.

◆ SIG_ALLOC

#define SIG_ALLOC (   PTR)     MEMZALLOC(PTR, struct sscop_sig *, sizeof(struct sscop_sig))

Definition at line 73 of file ng_sscop_cust.h.

◆ SIG_FREE

#define SIG_FREE (   PTR)     MEMFREE(PTR)

Definition at line 75 of file ng_sscop_cust.h.

◆ SIGQ_APPEND

#define SIGQ_APPEND (   Q,
 
)    TAILQ_INSERT_TAIL(Q, S, link)

Definition at line 182 of file ng_sscop_cust.h.

◆ SIGQ_CLEAR

#define SIGQ_CLEAR (   Q)
Value:
do { \
struct sscop_sig *_s1, *_s2; \
\
_s1 = TAILQ_FIRST(Q); \
while (_s1 != NULL) { \
_s2 = TAILQ_NEXT(_s1, link); \
SSCOP_MSG_FREE(_s1->msg); \
SIG_FREE(_s1); \
_s1 = _s2; \
} \
TAILQ_INIT(Q); \
} while (0)

Definition at line 220 of file ng_sscop_cust.h.

◆ SIGQ_EMPTY

#define SIGQ_EMPTY (   Q)    TAILQ_EMPTY(Q)

Definition at line 183 of file ng_sscop_cust.h.

◆ SIGQ_GET

#define SIGQ_GET (   Q)    ng_sscop_sigq_get((Q))

Definition at line 185 of file ng_sscop_cust.h.

◆ SIGQ_INIT

#define SIGQ_INIT (   Q)    TAILQ_INIT(Q)

Definition at line 181 of file ng_sscop_cust.h.

◆ SIGQ_MOVE

#define SIGQ_MOVE (   F,
 
)
Value:
do { \
struct sscop_sig *_s; \
\
while (!TAILQ_EMPTY(F)) { \
_s = TAILQ_FIRST(F); \
TAILQ_REMOVE(F, _s, link); \
TAILQ_INSERT_TAIL(T, _s, link); \
} \
} while (0)

Definition at line 198 of file ng_sscop_cust.h.

◆ SIGQ_PREPEND

#define SIGQ_PREPEND (   F,
 
)
Value:
do { \
struct sscop_sig *_s; \
\
while (!TAILQ_EMPTY(F)) { \
_s = TAILQ_LAST(F, sscop_sigq); \
TAILQ_REMOVE(F, _s, link); \
TAILQ_INSERT_HEAD(T, _s, link); \
} \
} while (0)

Definition at line 209 of file ng_sscop_cust.h.

◆ TIMER_FUNC

#define TIMER_FUNC (   T,
 
)
Value:
static void \
T##_func(node_p node, hook_p hook, void *arg1, int arg2) \
{ \
struct sscop *sscop = arg1; \
VERBOSE(sscop, SSCOP_DBG_TIMER, (sscop, sscop->aarg, \
"timer_" #T " expired")); \
sscop_signal(sscop, SIG_T_##N, NULL); \
}
#define VERBOSE(P, M, F)
Definition: ng_sscop.c:67

Definition at line 125 of file ng_sscop_cust.h.

◆ TIMER_INIT

#define TIMER_INIT (   S,
 
)    ng_callout_init(&(S)->t_##T)

Definition at line 111 of file ng_sscop_cust.h.

◆ TIMER_ISACT

#define TIMER_ISACT (   S,
 
)    (callout_pending(&(S)->t_##T))

Definition at line 120 of file ng_sscop_cust.h.

◆ TIMER_RESTART

#define TIMER_RESTART (   S,
 
)
Value:
do { \
TIMER_STOP(S, T); \
ng_callout(&(S)->t_##T, (S)->aarg, NULL, \
hz * (S)->timer##T / 1000, T##_func, (S), 0); \
} while (0)

Definition at line 115 of file ng_sscop_cust.h.

◆ TIMER_STOP

#define TIMER_STOP (   S,
 
)
Value:
do { \
ng_uncallout(&(S)->t_##T, (S)->aarg); \
} while (0)

Definition at line 112 of file ng_sscop_cust.h.

Typedef Documentation

◆ sscop_timer_t

typedef struct callout sscop_timer_t

Definition at line 110 of file ng_sscop_cust.h.

Function Documentation

◆ ng_sscop_mbuf_get32()

static uint32_t __inline ng_sscop_mbuf_get32 ( struct mbuf *  m)
static

Definition at line 275 of file ng_sscop_cust.h.

◆ ng_sscop_mbuf_pad4()

static u_int __inline ng_sscop_mbuf_pad4 ( struct mbuf *  m)
static

Definition at line 302 of file ng_sscop_cust.h.

References pad.

◆ ng_sscop_mbuf_strip32()

static uint32_t __inline ng_sscop_mbuf_strip32 ( struct mbuf *  m)
static

Definition at line 263 of file ng_sscop_cust.h.

◆ ng_sscop_mbuf_trail32()

static uint32_t __inline ng_sscop_mbuf_trail32 ( const struct mbuf *  m,
int  i 
)
static

Definition at line 249 of file ng_sscop_cust.h.

◆ TAILQ_ENTRY() [1/2]

typedef TAILQ_ENTRY ( sscop_msg  )

◆ TAILQ_ENTRY() [2/2]

typedef TAILQ_ENTRY ( sscop_sig  )

◆ TAILQ_HEAD() [1/2]

typedef TAILQ_HEAD ( sscop_msgq  ,
sscop_msg   
)

◆ TAILQ_HEAD() [2/2]

typedef TAILQ_HEAD ( sscop_sigq  ,
sscop_sig   
)