Browse Source

* document ipaddr.h

master
Alex 'AdUser' Z 8 years ago
parent
commit
6224ab0ddf
  1. 49
      src/ipaddr.h

49
src/ipaddr.h

@ -13,26 +13,51 @@
#include "matches.h" #include "matches.h"
/**
* @def IPADDR_MAX
* Maximum text length of address
*/
#define IPADDR_MAX 48 /* 8 x "ffff" + 7 x "::" + '\0' */ #define IPADDR_MAX 48 /* 8 x "ffff" + 7 x "::" + '\0' */
/**
* @struct f2b_ipaddr_t
* Describes ip-address and it's metadata
*/
typedef struct f2b_ipaddr_t { typedef struct f2b_ipaddr_t {
struct f2b_ipaddr_t *next; struct f2b_ipaddr_t *next; /**< pointer to next addr */
int type; int type; /**< address type, AF_INET/AF_INET6 */
char text[IPADDR_MAX]; char text[IPADDR_MAX]; /**< textual address */
bool banned; bool banned; /**< is address banned, flag */
size_t bancount; size_t bancount; /**< how many times this address was banned */
time_t lastseen; time_t lastseen; /**< self-descriptive, unixtime */
time_t banned_at; time_t banned_at; /**< self-descriptive, unixtime */
time_t release_at; time_t release_at; /**< self-descriptive, unixtime */
union { union {
struct in_addr v4; struct in_addr v4; /**< AF_INET address */
struct in6_addr v6; struct in6_addr v6; /**< AF_INET6 address */
} binary; } binary; /**< binary address representation, see @a type */
f2b_matches_t matches; f2b_matches_t matches; /**< list of matches */
} f2b_ipaddr_t; } f2b_ipaddr_t;
/**
* @brief Create address record and fill related metadata
* @param addr Textual address
* @param max_matches Maximum matches count
* @returns Pointer to address or NULL no error
*/
f2b_ipaddr_t * f2b_ipaddr_create (const char *addr, size_t max_matches); f2b_ipaddr_t * f2b_ipaddr_create (const char *addr, size_t max_matches);
/**
* @brief Free address metadata
* @param ipaddr Pointer to f2b_ipaddr_t struct
* @note @a ipaddr pointer becomes invalid after calling this function
*/
void f2b_ipaddr_destroy(f2b_ipaddr_t *ipaddr); void f2b_ipaddr_destroy(f2b_ipaddr_t *ipaddr);
/**
* @brief Get some stats about given address
* @param ipaddr Pointer to f2b_ipaddr_t struct
* @param res Buffer for storing stats
* @param ressize Size of buffer above
*/
void f2b_ipaddr_status (f2b_ipaddr_t *ipaddr, char *res, size_t ressize); void f2b_ipaddr_status (f2b_ipaddr_t *ipaddr, char *res, size_t ressize);
f2b_ipaddr_t * f2b_addrlist_append(f2b_ipaddr_t *list, f2b_ipaddr_t *ipaddr); f2b_ipaddr_t * f2b_addrlist_append(f2b_ipaddr_t *list, f2b_ipaddr_t *ipaddr);

Loading…
Cancel
Save