31 #define SNSD_MAX_RECORDS 256
34 #define SNSD_MAX_QUEUE_RECORDS 1
36 #define SNSD_MAX_REC_SERV 16
38 #define SNSD_ALL_SERVICE (-1)
41 #define SNSD_DEFAULT_SERVICE 0
42 #define SNSD_DEFAULT_PROTO 1
43 #define SNSD_DEFAULT_PRIO 16
44 #define SNSD_DEFAULT_WEIGHT 1
46 #define SNSD_WEIGHT(x) ((x) & 0x7f)
52 #define MAX_SNSD_LINE_SZ (ANDNA_MAX_HNAME_LEN*4)
53 #define MAX_SNSD_FIELDS 6
54 #define MIN_SNSD_FIELDS 5
57 #define SNSD_NODE_HNAME 1
59 #define SNSD_NODE_IP (1<<1)
61 #define SNSD_NODE_MAIN_IP (1<<2)
112 #define SNSD_NODE_PACK_SZ (MAX_IP_SZ+sizeof(char)*2)
123 #define SNSD_PRIO_PACK_SZ (sizeof(char))
136 #define SNSD_SERVICE_PACK_SZ (sizeof(u_short)+sizeof(u_char))
160 #define SNSD_NODE_LLIST_PACK_SZ(head) (list_count((head))*SNSD_NODE_PACK_SZ \
161 + sizeof(struct snsd_node_llist_hdr))
177 #define SNSD_PRIO_LLIST_PACK_SZ(head) \
179 snsd_prio *_p=(head); \
183 _priosz+=SNSD_NODE_LLIST_PACK_SZ(_p->node); \
184 _priosz+=SNSD_PRIO_PACK_SZ; \
186 _priosz+=sizeof(struct snsd_prio_llist_hdr); \
202 #define SNSD_SERVICE_LLIST_PACK_SZ(head) \
204 snsd_service *_s=(head); \
208 _srvsz+=SNSD_PRIO_LLIST_PACK_SZ(_s->prio); \
209 _srvsz+=SNSD_SERVICE_PACK_SZ; \
211 _srvsz+=sizeof(struct snsd_service_llist_hdr); \
216 #define SNSD_SERVICE_SINGLE_PACK_SZ(head) \
217 ({ SNSD_SERVICE_PACK_SZ + \
218 SNSD_PRIO_LLIST_PACK_SZ((head)->prio); \
221 #define SNSD_SERVICE_MAX_PACK_SZ \
222 ( ( (SNSD_NODE_PACK_SZ + SNSD_PRIO_PACK_SZ) * \
223 (SNSD_MAX_REC_SERV) ) + \
224 SNSD_SERVICE_PACK_SZ + \
225 sizeof(struct snsd_prio_llist_hdr) + \
226 sizeof(struct snsd_service_llist_hdr) \
229 #define SNSD_SERVICE_MAX_LLIST_PACK_SZ \
230 (( SNSD_NODE_PACK_SZ + SNSD_PRIO_PACK_SZ + SNSD_SERVICE_PACK_SZ + \
231 sizeof(struct snsd_prio_llist_hdr))*SNSD_MAX_RECORDS + \
232 sizeof(struct snsd_service_llist_hdr) \
273 u_short max_records, u_int record[
MAX_IP_INT]);
275 u_short max_records, u_int record[
MAX_IP_INT]);
282 size_t *unpacked_sz, u_short *nodes_counter);
285 size_t *unpacked_sz, u_short *nodes_counter);
snsd_service * snsd_unpack_all_service(char *pack, size_t pack_sz, size_t *unpacked_sz, u_short *nodes_counter)
Definition: snsd_cache.c:780
void snsd_merge_node(snsd_node **head, u_short *snsd_counter, snsd_node *new)
Definition: snsd_cache.c:1045
char flags
Definition: snsd_cache.h:105
snsd_node * snsd_choose_wrand(snsd_node *head)
Definition: snsd_cache.c:865
snsd_service * snsd_unpack_service(char *pack, size_t pack_sz, size_t *unpacked_sz, u_short *nodes_counter)
Definition: snsd_cache.c:706
const char * snsd_proto_to_str(u_char proto)
Definition: snsd_cache.c:62
int snsd_count_prio_nodes(snsd_prio *head)
Definition: snsd_cache.c:839
Definition: snsd_cache.h:114
void snsd_merge_service(snsd_service **head, u_short *snsd_counter, snsd_service *new)
Definition: snsd_cache.c:1081
struct snsd_node_llist_hdr _PACKED_
static const int_info snsd_prio_llist_hdr_iinfo
Definition: snsd_cache.h:168
Definition: snsd_cache.h:97
u_short service
Definition: snsd_cache.h:129
#define INT_TYPE_16BIT
Definition: endianness.h:36
static const int_info snsd_node_llist_hdr_iinfo
Definition: snsd_cache.h:150
Definition: snsd_cache.h:163
void snsd_prio_llist_merge(snsd_prio **dst, u_short *snsd_counter, snsd_prio *src)
Definition: snsd_cache.c:1075
struct servent * snsd_service_to_str(int service, u_char proto, char **service_str, char **proto_str)
Definition: snsd_cache.c:120
void snsd_cache_init(int family)
Definition: snsd_cache.c:35
Definition: snsd_cache.h:145
u_short count
Definition: snsd_cache.h:147
snsd_prio * prio
Definition: snsd_cache.h:133
void snsd_node_llist_merge(snsd_node **dst, u_short *snsd_counter, snsd_node *src)
Definition: snsd_cache.c:1057
u_char proto
Definition: snsd_cache.h:130
snsd_node * node
Definition: snsd_cache.h:120
u_short count
Definition: snsd_cache.h:193
snsd_service * snsd_service_llist_copy(snsd_service *sns, int service, u_char proto)
Definition: snsd_cache.c:1016
Definition: snsd_cache.h:125
snsd_node * snsd_add_node(snsd_node **head, u_short *counter, u_short max_records, u_int record[4])
Definition: snsd_cache.c:211
int str_to_snsd_service(char *str, int *service, u_char *proto)
Definition: snsd_cache.c:84
void snsd_service_llist_merge(snsd_service **dst, u_short *snsd_counter, snsd_service *src)
Definition: snsd_cache.c:1106
int snsd_pack_all_services(char *pack, size_t pack_sz, snsd_service *head)
Definition: snsd_cache.c:746
u_char weight
Definition: snsd_cache.h:108
snsd_node * snsd_find_mainip(snsd_service *sns)
Definition: snsd_cache.c:913
void snsd_service_llist_del(snsd_service **head)
Definition: snsd_cache.c:295
#define MAX_IP_INT
Definition: inet.h:24
void snsd_record_del_selected(snsd_service **head, u_short *snd_counter, snsd_service *selected)
Definition: snsd_cache.c:314
RSA * pubkey
Definition: snsd_cache.h:104
u_short count
Definition: snsd_cache.h:165
snsd_prio * snsd_highest_prio(snsd_prio *head)
Definition: snsd_cache.c:894
u_char str_to_snsd_proto(char *proto_name)
Definition: snsd_cache.c:48
snsd_prio * snsd_add_prio(snsd_prio **head, u_char prio)
Definition: snsd_cache.c:177
u_int record[4]
Definition: snsd_cache.h:101
Definition: snsd_cache.h:191
snsd_node * snsd_add_mainip(snsd_service **head, u_short *counter, u_short max_records, u_int record[4])
Definition: snsd_cache.c:252
snsd_node * snsd_find_node_by_record(snsd_node *snd, u_int record[4])
Definition: snsd_cache.c:192
static const int_info snsd_service_llist_hdr_iinfo
Definition: snsd_cache.h:195
#define INT_INFO
Definition: endianness.h:90
void snsd_merge_prio(snsd_prio **head, u_short *snsd_counter, snsd_prio *new)
Definition: snsd_cache.c:1063
void snsd_unset_all_flags(snsd_service *sns, u_char flag)
Definition: snsd_cache.c:936
static const char proto_str[][5]
Definition: snsd_cache.h:245
int snsd_pack_service(char *pack, size_t free_sz, snsd_service *service)
Definition: snsd_cache.c:670
#define LLIST_HDR(_struct)
Definition: llist.c:44
int snsd_count_nodes(snsd_node *head)
Definition: snsd_cache.c:834
int family
Definition: if.c:34
snsd_prio * snsd_find_prio(snsd_prio *snp, u_char prio)
Definition: snsd_cache.c:169
int snsd_count_service_nodes(snsd_service *head)
Definition: snsd_cache.c:848
u_char prio
Definition: snsd_cache.h:118
snsd_service * snsd_find_service(snsd_service *sns, u_short service, u_char proto)
Definition: snsd_cache.c:141
snsd_service * snsd_add_service(snsd_service **head, u_short service, u_char proto)
Definition: snsd_cache.c:152