af-packet: add doxygen comments

This patch adds doxygen comments to newly introduced function and adds
module AF_PACKET doxygen module with a dedicated AFP peers module.
pull/48/merge
Eric Leblond 13 years ago committed by Victor Julien
parent 662dccd8a5
commit a645726262

@ -15,6 +15,12 @@
* 02110-1301, USA. * 02110-1301, USA.
*/ */
/**
* \ingroup afppacket
*
* @{
*/
/** /**
* \file * \file
* *
@ -507,3 +513,7 @@ int RunModeIdsAFPWorkers(DetectEngineCtx *de_ctx)
#endif /* HAVE_AF_PACKET */ #endif /* HAVE_AF_PACKET */
SCReturnInt(0); SCReturnInt(0);
} }
/**
* @}
*/

@ -15,6 +15,12 @@
* 02110-1301, USA. * 02110-1301, USA.
*/ */
/**
* \defgroup afppacket AF_PACKET running mode
*
* @{
*/
/** /**
* \file * \file
* *
@ -218,6 +224,20 @@ void TmModuleReceiveAFPRegister (void) {
tmm_modules[TMM_RECEIVEAFP].flags = TM_FLAG_RECEIVE_TM; tmm_modules[TMM_RECEIVEAFP].flags = TM_FLAG_RECEIVE_TM;
} }
/**
* \defgroup afppeers AFP peers list
*
* AF_PACKET has an IPS mode were interface are peered: packet from
* on interface are sent the peered interface and the other way. The ::AFPPeer
* list is maitaining the list of peers. Each ::AFPPeer is storing the needed
* information to be able to send packet on the interface.
* A element of the list must not be destroyed during the run of Suricata as it
* is used by ::Packet and other threads.
*
* @{
*/
typedef struct AFPPeersList_ { typedef struct AFPPeersList_ {
TAILQ_HEAD(, AFPPeer_) peers; /**< Head of list of fragments. */ TAILQ_HEAD(, AFPPeer_) peers; /**< Head of list of fragments. */
int cnt; int cnt;
@ -225,7 +245,11 @@ typedef struct AFPPeersList_ {
} AFPPeersList; } AFPPeersList;
/** /**
* Update the peer. * \brief Update the peer.
*
* Update the AFPPeer of a thread ie set new state, socket number
* or iface index.
*
*/ */
void AFPPeerUpdate(AFPThreadVars *ptv) void AFPPeerUpdate(AFPThreadVars *ptv)
{ {
@ -238,6 +262,9 @@ void AFPPeerUpdate(AFPThreadVars *ptv)
(void)SC_ATOMIC_SET(ptv->mpeer->state, ptv->afp_state); (void)SC_ATOMIC_SET(ptv->mpeer->state, ptv->afp_state);
} }
/**
* \brief Clean and free ressource used by an ::AFPPeer
*/
void AFPPeerClean(AFPPeer *peer) void AFPPeerClean(AFPPeer *peer)
{ {
if (peer->flags & AFP_SOCK_PROTECT) if (peer->flags & AFP_SOCK_PROTECT)
@ -251,6 +278,9 @@ void AFPPeerClean(AFPPeer *peer)
AFPPeersList peerslist; AFPPeersList peerslist;
/**
* \brief Init the global list of ::AFPPeer
*/
TmEcode AFPPeersListInit() TmEcode AFPPeersListInit()
{ {
SCEnter(); SCEnter();
@ -260,6 +290,11 @@ TmEcode AFPPeersListInit()
SCReturnInt(TM_ECODE_OK); SCReturnInt(TM_ECODE_OK);
} }
/**
* \brief Check that all ::AFPPeer got a peer
*
* \retval TM_ECODE_FAILED if some threads are not peered or TM_ECODE_OK else.
*/
TmEcode AFPPeersListCheck() TmEcode AFPPeersListCheck()
{ {
#define AFP_PEERS_MAX_TRY 4 #define AFP_PEERS_MAX_TRY 4
@ -278,6 +313,9 @@ TmEcode AFPPeersListCheck()
SCReturnInt(TM_ECODE_FAILED); SCReturnInt(TM_ECODE_FAILED);
} }
/**
* \brief Declare a new AFP thread to AFP peers list.
*/
TmEcode AFPPeersListAdd(AFPThreadVars *ptv) TmEcode AFPPeersListAdd(AFPThreadVars *ptv)
{ {
SCEnter(); SCEnter();
@ -321,6 +359,9 @@ TmEcode AFPPeersListAdd(AFPThreadVars *ptv)
SCReturnInt(TM_ECODE_OK); SCReturnInt(TM_ECODE_OK);
} }
/**
* \brief Clean the global peers list.
*/
void AFPPeersListClean() void AFPPeersListClean()
{ {
AFPPeer *pitem; AFPPeer *pitem;
@ -331,6 +372,10 @@ void AFPPeersListClean()
} }
} }
/**
* @}
*/
/** /**
* \brief Registration Function for DecodeAFP. * \brief Registration Function for DecodeAFP.
* \todo Unit tests are needed for this module. * \todo Unit tests are needed for this module.
@ -1387,3 +1432,6 @@ TmEcode DecodeAFPThreadInit(ThreadVars *tv, void *initdata, void **data)
#endif /* HAVE_AF_PACKET */ #endif /* HAVE_AF_PACKET */
/* eof */ /* eof */
/**
* @}
*/

@ -74,6 +74,11 @@ typedef struct AFPIfaceConfig_
void (*DerefFunc)(void *); void (*DerefFunc)(void *);
} AFPIfaceConfig; } AFPIfaceConfig;
/**
* \ingroup afppeers
* @{
*/
typedef struct AFPPeer_ { typedef struct AFPPeer_ {
char iface[AFP_IFACE_NAME_LENGTH]; char iface[AFP_IFACE_NAME_LENGTH];
SC_ATOMIC_DECLARE(int, socket); SC_ATOMIC_DECLARE(int, socket);
@ -93,6 +98,9 @@ typedef struct AFPPacketVars_
AFPPeer *peer; AFPPeer *peer;
} AFPPacketVars; } AFPPacketVars;
/**
* @}
*/
void TmModuleReceiveAFPRegister (void); void TmModuleReceiveAFPRegister (void);
void TmModuleDecodeAFPRegister (void); void TmModuleDecodeAFPRegister (void);

Loading…
Cancel
Save