The Netsukuku Project  0.0.9
An Alternative routing method
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
snsd_cache.h File Reference
#include "inet.h"
#include "crypto.h"
#include "endianness.h"
#include "llist.c"
Include dependency graph for snsd_cache.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  snsd_node
 
struct  snsd_prio
 
struct  snsd_service
 
struct  snsd_node_llist_hdr
 
struct  snsd_prio_llist_hdr
 
struct  snsd_service_llist_hdr
 

Macros

#define SNSD_MAX_RECORDS
 
#define SNSD_MAX_QUEUE_RECORDS
 
#define SNSD_MAX_REC_SERV   16 /* Maximum records per service */
 
#define SNSD_ALL_SERVICE
 
#define SNSD_DEFAULT_SERVICE   0
 
#define SNSD_DEFAULT_PROTO   1 /* tcp */
 
#define SNSD_DEFAULT_PRIO   16
 
#define SNSD_DEFAULT_WEIGHT   1
 
#define SNSD_WEIGHT(x)
 
#define MAX_SNSD_LINE_SZ   (ANDNA_MAX_HNAME_LEN*4)
 
#define MAX_SNSD_FIELDS   6
 
#define MIN_SNSD_FIELDS   5
 
#define SNSD_NODE_HNAME
 
#define SNSD_NODE_IP
 
#define SNSD_NODE_MAIN_IP
 
#define SNSD_NODE_PACK_SZ   (MAX_IP_SZ+sizeof(char)*2)
 
#define SNSD_PRIO_PACK_SZ   (sizeof(char))
 
#define SNSD_SERVICE_PACK_SZ   (sizeof(u_short)+sizeof(u_char))
 
#define SNSD_NODE_LLIST_PACK_SZ(head)
 
#define SNSD_PRIO_LLIST_PACK_SZ(head)
 
#define SNSD_SERVICE_LLIST_PACK_SZ(head)
 
#define SNSD_SERVICE_SINGLE_PACK_SZ(head)
 
#define SNSD_SERVICE_MAX_PACK_SZ
 
#define SNSD_SERVICE_MAX_LLIST_PACK_SZ
 

Typedefs

typedef struct snsd_node snsd_node
 
typedef struct snsd_prio snsd_prio
 
typedef struct snsd_service snsd_service
 

Functions

void snsd_cache_init (int family)
 
u_char str_to_snsd_proto (char *proto_name)
 
const char * snsd_proto_to_str (u_char proto)
 
int str_to_snsd_service (char *str, int *service, u_char *proto)
 
struct servent * snsd_service_to_str (int service, u_char proto, char **service_str, char **proto_str)
 
snsd_servicesnsd_find_service (snsd_service *sns, u_short service, u_char proto)
 
snsd_servicesnsd_add_service (snsd_service **head, u_short service, u_char proto)
 
snsd_priosnsd_find_prio (snsd_prio *snp, u_char prio)
 
snsd_priosnsd_add_prio (snsd_prio **head, u_char prio)
 
snsd_nodesnsd_find_node_by_record (snsd_node *snd, u_int record[4])
 
snsd_nodesnsd_add_node (snsd_node **head, u_short *counter, u_short max_records, u_int record[4])
 
snsd_nodesnsd_add_mainip (snsd_service **head, u_short *counter, u_short max_records, u_int record[4])
 
void snsd_service_llist_del (snsd_service **head)
 
void snsd_record_del_selected (snsd_service **head, u_short *snd_counter, snsd_service *selected)
 
int snsd_pack_service (char *pack, size_t free_sz, snsd_service *service)
 
snsd_servicesnsd_unpack_service (char *pack, size_t pack_sz, size_t *unpacked_sz, u_short *nodes_counter)
 
int snsd_pack_all_services (char *pack, size_t pack_sz, snsd_service *head)
 
snsd_servicesnsd_unpack_all_service (char *pack, size_t pack_sz, size_t *unpacked_sz, u_short *nodes_counter)
 
snsd_nodesnsd_choose_wrand (snsd_node *head)
 
snsd_priosnsd_highest_prio (snsd_prio *head)
 
snsd_nodesnsd_find_mainip (snsd_service *sns)
 
void snsd_unset_all_flags (snsd_service *sns, u_char flag)
 
snsd_servicesnsd_service_llist_copy (snsd_service *sns, int service, u_char proto)
 
void snsd_merge_node (snsd_node **head, u_short *snsd_counter, snsd_node *new)
 
void snsd_node_llist_merge (snsd_node **dst, u_short *snsd_counter, snsd_node *src)
 
void snsd_merge_prio (snsd_prio **head, u_short *snsd_counter, snsd_prio *new)
 
void snsd_prio_llist_merge (snsd_prio **dst, u_short *snsd_counter, snsd_prio *src)
 
void snsd_merge_service (snsd_service **head, u_short *snsd_counter, snsd_service *new)
 
void snsd_service_llist_merge (snsd_service **dst, u_short *snsd_counter, snsd_service *src)
 
int snsd_count_nodes (snsd_node *head)
 
int snsd_count_prio_nodes (snsd_prio *head)
 
int snsd_count_service_nodes (snsd_service *head)
 

Variables

struct snsd_node_llist_hdr _PACKED_
 
static const int_info snsd_node_llist_hdr_iinfo = { 1, { (1<<1) }, { 0 }, { 1 } }
 
static const int_info snsd_prio_llist_hdr_iinfo = { 1, { (1<<1) }, { 0 }, { 1 } }
 
static const int_info snsd_service_llist_hdr_iinfo = { 1, { (1<<1) }, { 0 }, { 1 } }
 
static const char proto_str [][5]
 

Macro Definition Documentation

#define MAX_SNSD_FIELDS   6
#define MAX_SNSD_LINE_SZ   (ANDNA_MAX_HNAME_LEN*4)
#define MIN_SNSD_FIELDS   5
#define SNSD_ALL_SERVICE
Value:
(-1) /* A service number equal to -1
refers to all the available
services */
#define SNSD_DEFAULT_PRIO   16
#define SNSD_DEFAULT_PROTO   1 /* tcp */
#define SNSD_DEFAULT_SERVICE   0
#define SNSD_DEFAULT_WEIGHT   1
#define SNSD_MAX_QUEUE_RECORDS
Value:
1 /* There can be only one snsd
record for the queued hnames */
#define SNSD_MAX_REC_SERV   16 /* Maximum records per service */
#define SNSD_MAX_RECORDS
Value:
256 /* Number of maximum SNSD records
which can be stored in an
andna_cache */
#define SNSD_NODE_HNAME
Value:
1 /* A hname is associated in the
snsd record */
#define SNSD_NODE_IP
Value:
(1<<1) /* An IP is associated in the
snsd record */
#define SNSD_NODE_LLIST_PACK_SZ (   head)
Value:
+ sizeof(struct snsd_node_llist_hdr))
Definition: snsd_cache.h:145
#define list_count(_head)
Definition: llist.c:379
#define SNSD_NODE_PACK_SZ
Definition: snsd_cache.h:112
#define SNSD_NODE_MAIN_IP
Value:
(1<<2) /* This is the first IP registered
to the hname, it can't be
deleted */
#define SNSD_NODE_PACK_SZ   (MAX_IP_SZ+sizeof(char)*2)
#define SNSD_PRIO_LLIST_PACK_SZ (   head)
Value:
({ \
snsd_prio *_p=(head); \
int _priosz=0; \
list_for(_p) { \
_priosz+=SNSD_NODE_LLIST_PACK_SZ(_p->node); \
_priosz+=SNSD_PRIO_PACK_SZ; \
} \
_priosz+=sizeof(struct snsd_prio_llist_hdr); \
_priosz; \
})
struct snsd_prio snsd_prio
Definition: snsd_cache.h:122
#define SNSD_NODE_LLIST_PACK_SZ(head)
Definition: snsd_cache.h:160
Definition: snsd_cache.h:163
#define SNSD_PRIO_PACK_SZ
Definition: snsd_cache.h:123
#define list_for(i)
Definition: llist.c:372
#define SNSD_PRIO_PACK_SZ   (sizeof(char))
#define SNSD_SERVICE_LLIST_PACK_SZ (   head)
Value:
({ \
snsd_service *_s=(head); \
int _srvsz=0; \
if(_s) { \
list_for(_s) { \
_srvsz+=SNSD_PRIO_LLIST_PACK_SZ(_s->prio); \
} \
_srvsz+=sizeof(struct snsd_service_llist_hdr); \
} \
_srvsz; \
})
#define SNSD_SERVICE_PACK_SZ
Definition: snsd_cache.h:136
struct snsd_service snsd_service
Definition: snsd_cache.h:135
#define SNSD_PRIO_LLIST_PACK_SZ(head)
Definition: snsd_cache.h:177
Definition: snsd_cache.h:191
#define list_for(i)
Definition: llist.c:372
#define SNSD_SERVICE_MAX_LLIST_PACK_SZ
Value:
sizeof(struct snsd_service_llist_hdr) \
)
Definition: snsd_cache.h:163
#define SNSD_MAX_RECORDS
Definition: snsd_cache.h:31
#define SNSD_SERVICE_PACK_SZ
Definition: snsd_cache.h:136
#define SNSD_PRIO_PACK_SZ
Definition: snsd_cache.h:123
Definition: snsd_cache.h:191
#define SNSD_NODE_PACK_SZ
Definition: snsd_cache.h:112
#define SNSD_SERVICE_MAX_PACK_SZ
Value:
sizeof(struct snsd_prio_llist_hdr) + \
sizeof(struct snsd_service_llist_hdr) \
)
Definition: snsd_cache.h:163
#define SNSD_SERVICE_PACK_SZ
Definition: snsd_cache.h:136
#define SNSD_MAX_REC_SERV
Definition: snsd_cache.h:36
#define SNSD_PRIO_PACK_SZ
Definition: snsd_cache.h:123
Definition: snsd_cache.h:191
#define SNSD_NODE_PACK_SZ
Definition: snsd_cache.h:112
#define SNSD_SERVICE_PACK_SZ   (sizeof(u_short)+sizeof(u_char))
#define SNSD_SERVICE_SINGLE_PACK_SZ (   head)
Value:
SNSD_PRIO_LLIST_PACK_SZ((head)->prio); \
})
#define SNSD_SERVICE_PACK_SZ
Definition: snsd_cache.h:136
#define SNSD_PRIO_LLIST_PACK_SZ(head)
Definition: snsd_cache.h:177
#define SNSD_WEIGHT (   x)
Value:
((x) & 0x7f) /* The snsd weight has to
be <= 127 */

Typedef Documentation

typedef struct snsd_node snsd_node
typedef struct snsd_prio snsd_prio
typedef struct snsd_service snsd_service

Function Documentation

snsd_node* snsd_add_mainip ( snsd_service **  head,
u_short *  counter,
u_short  max_records,
u_int  record[4] 
)

Here is the call graph for this function:

Here is the caller graph for this function:

snsd_node* snsd_add_node ( snsd_node **  head,
u_short *  counter,
u_short  max_records,
u_int  record[4] 
)

Here is the call graph for this function:

Here is the caller graph for this function:

snsd_prio* snsd_add_prio ( snsd_prio **  head,
u_char  prio 
)

Here is the call graph for this function:

Here is the caller graph for this function:

snsd_service* snsd_add_service ( snsd_service **  head,
u_short  service,
u_char  proto 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void snsd_cache_init ( int  family)

Here is the caller graph for this function:

snsd_node* snsd_choose_wrand ( snsd_node head)

Here is the call graph for this function:

int snsd_count_nodes ( snsd_node head)

Here is the caller graph for this function:

int snsd_count_prio_nodes ( snsd_prio head)

Here is the call graph for this function:

Here is the caller graph for this function:

int snsd_count_service_nodes ( snsd_service head)

Here is the call graph for this function:

snsd_node* snsd_find_mainip ( snsd_service sns)

Here is the caller graph for this function:

snsd_node* snsd_find_node_by_record ( snsd_node snd,
u_int  record[4] 
)

Here is the caller graph for this function:

snsd_prio* snsd_find_prio ( snsd_prio snp,
u_char  prio 
)

Here is the caller graph for this function:

snsd_service* snsd_find_service ( snsd_service sns,
u_short  service,
u_char  proto 
)

Here is the caller graph for this function:

snsd_prio* snsd_highest_prio ( snsd_prio head)
void snsd_merge_node ( snsd_node **  head,
u_short *  snsd_counter,
snsd_node new 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void snsd_merge_prio ( snsd_prio **  head,
u_short *  snsd_counter,
snsd_prio new 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void snsd_merge_service ( snsd_service **  head,
u_short *  snsd_counter,
snsd_service new 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void snsd_node_llist_merge ( snsd_node **  dst,
u_short *  snsd_counter,
snsd_node src 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int snsd_pack_all_services ( char *  pack,
size_t  pack_sz,
snsd_service head 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int snsd_pack_service ( char *  pack,
size_t  free_sz,
snsd_service service 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void snsd_prio_llist_merge ( snsd_prio **  dst,
u_short *  snsd_counter,
snsd_prio src 
)

Here is the call graph for this function:

Here is the caller graph for this function:

const char* snsd_proto_to_str ( u_char  proto)

Here is the caller graph for this function:

void snsd_record_del_selected ( snsd_service **  head,
u_short *  snd_counter,
snsd_service selected 
)

Here is the call graph for this function:

Here is the caller graph for this function:

snsd_service* snsd_service_llist_copy ( snsd_service sns,
int  service,
u_char  proto 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void snsd_service_llist_del ( snsd_service **  head)

Here is the call graph for this function:

Here is the caller graph for this function:

void snsd_service_llist_merge ( snsd_service **  dst,
u_short *  snsd_counter,
snsd_service src 
)

Here is the call graph for this function:

Here is the caller graph for this function:

struct servent* snsd_service_to_str ( int  service,
u_char  proto,
char **  service_str,
char **  proto_str 
)

Here is the call graph for this function:

snsd_service* snsd_unpack_all_service ( char *  pack,
size_t  pack_sz,
size_t *  unpacked_sz,
u_short *  nodes_counter 
)

Here is the call graph for this function:

Here is the caller graph for this function:

snsd_service* snsd_unpack_service ( char *  pack,
size_t  pack_sz,
size_t *  unpacked_sz,
u_short *  nodes_counter 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void snsd_unset_all_flags ( snsd_service sns,
u_char  flag 
)

Here is the caller graph for this function:

u_char str_to_snsd_proto ( char *  proto_name)

Here is the caller graph for this function:

int str_to_snsd_service ( char *  str,
int *  service,
u_char *  proto 
)

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const char proto_str[][5]
static
Initial value:
=
{
{ "tcp" },
{ "udp" },
{ 0 },
}
const int_info snsd_node_llist_hdr_iinfo = { 1, { (1<<1) }, { 0 }, { 1 } }
static
const int_info snsd_prio_llist_hdr_iinfo = { 1, { (1<<1) }, { 0 }, { 1 } }
static
const int_info snsd_service_llist_hdr_iinfo = { 1, { (1<<1) }, { 0 }, { 1 } }
static