Changeset 82:b6344f1d521a in freeDiameter for include
- Timestamp:
- Dec 2, 2009, 2:20:38 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
include/freeDiameter/freeDiameter.h
r78 r82 115 115 extern struct fd_config *fd_g_config; /* The pointer to access the global configuration, initalized in main */ 116 116 117 /* Endpoints */118 struct fd_endpoint {119 struct fd_list chain; /* link in cnf_endpoints list */120 121 union {122 sSS ss; /* the socket information. List is always ordered by ss value (memcmp) -- see fd_ep_add_merge */123 sSA4 sin;124 sSA6 sin6;125 sSA sa;126 };127 128 #define EP_FL_CONF (1 << 0) /* This endpoint is statically configured in a configuration file */129 #define EP_FL_DISC (1 << 1) /* This endpoint was resolved from the Diameter Identity or other DNS query */130 #define EP_FL_ADV (1 << 2) /* This endpoint was advertized in Diameter CER/CEA exchange */131 #define EP_FL_LL (1 << 3) /* Lower layer mechanism provided this endpoint */132 #define EP_FL_PRIMARY (1 << 4) /* This endpoint is primary in a multihomed SCTP association */133 uint32_t flags; /* Additional information about the endpoint */134 135 /* To add: a validity timestamp for DNS records ? How do we retrieve this lifetime from DNS ? */136 };137 138 /* Applications */139 struct fd_app {140 struct fd_list chain; /* link in cnf_apps list. List ordered by appid. */141 struct {142 unsigned auth : 1;143 unsigned acct : 1;144 unsigned common : 1;145 } flags;146 vendor_id_t vndid; /* if not 0, Vendor-Specific-App-Id AVP will be used */147 application_id_t appid; /* The identifier of the application */148 };149 150 151 /* Events */152 struct fd_event {153 int code; /* codespace depends on the queue */154 size_t size;155 void *data;156 };157 158 /* Daemon's codespace: 1000->1999 */159 enum {160 FDEV_TERMINATE = 1000 /* request to terminate */161 ,FDEV_DUMP_DICT /* Dump the content of the dictionary */162 ,FDEV_DUMP_EXT /* Dump state of extensions */163 ,FDEV_DUMP_SERV /* Dump the server socket status */164 ,FDEV_DUMP_QUEUES /* Dump the message queues */165 ,FDEV_DUMP_CONFIG /* Dump the configuration */166 ,FDEV_DUMP_PEERS /* Dump the list of peers */167 };168 169 static __inline__ int fd_event_send(struct fifo *queue, int code, size_t datasz, void * data)170 {171 struct fd_event * ev;172 CHECK_MALLOC( ev = malloc(sizeof(struct fd_event)) );173 ev->code = code;174 ev->size = datasz;175 ev->data = data;176 CHECK_FCT( fd_fifo_post(queue, &ev) );177 return 0;178 }179 static __inline__ int fd_event_get(struct fifo *queue, int *code, size_t *datasz, void ** data)180 {181 struct fd_event * ev;182 CHECK_FCT( fd_fifo_get(queue, &ev) );183 if (code)184 *code = ev->code;185 if (datasz)186 *datasz = ev->size;187 if (data)188 *data = ev->data;189 free(ev);190 return 0;191 }192 static __inline__ int fd_event_timedget(struct fifo *queue, struct timespec * timeout, int timeoutcode, int *code, size_t *datasz, void ** data)193 {194 struct fd_event * ev;195 int ret = 0;196 ret = fd_fifo_timedget(queue, &ev, timeout);197 if (ret == ETIMEDOUT) {198 if (code)199 *code = timeoutcode;200 if (datasz)201 *datasz = 0;202 if (data)203 *data = NULL;204 } else {205 CHECK_FCT( ret );206 if (code)207 *code = ev->code;208 if (datasz)209 *datasz = ev->size;210 if (data)211 *data = ev->data;212 free(ev);213 }214 return 0;215 }216 static __inline__ void fd_event_destroy(struct fifo **queue, void (*free_cb)(void * data))217 {218 struct fd_event * ev;219 /* Purge all events, and free the associated data if any */220 while (fd_fifo_tryget( *queue, &ev ) == 0) {221 (*free_cb)(ev->data);222 free(ev);223 }224 CHECK_FCT_DO( fd_fifo_del(queue), /* continue */ );225 return ;226 }227 const char * fd_ev_str(int event); /* defined in freeDiameter/main.c */228 229 117 230 118 /***************************************/ … … 539 427 540 428 /***************************************/ 429 /* Events helpers */ 430 /***************************************/ 431 432 /* Events */ 433 struct fd_event { 434 int code; /* codespace depends on the queue */ 435 size_t size; 436 void *data; 437 }; 438 439 /* Daemon's codespace: 1000->1999 */ 440 enum { 441 FDEV_TERMINATE = 1000 /* request to terminate */ 442 ,FDEV_DUMP_DICT /* Dump the content of the dictionary */ 443 ,FDEV_DUMP_EXT /* Dump state of extensions */ 444 ,FDEV_DUMP_SERV /* Dump the server socket status */ 445 ,FDEV_DUMP_QUEUES /* Dump the message queues */ 446 ,FDEV_DUMP_CONFIG /* Dump the configuration */ 447 ,FDEV_DUMP_PEERS /* Dump the list of peers */ 448 }; 449 450 int fd_event_send(struct fifo *queue, int code, size_t datasz, void * data); 451 int fd_event_get(struct fifo *queue, int *code, size_t *datasz, void ** data); 452 int fd_event_timedget(struct fifo *queue, struct timespec * timeout, int timeoutcode, int *code, size_t *datasz, void ** data); 453 void fd_event_destroy(struct fifo **queue, void (*free_cb)(void * data)); 454 const char * fd_ev_str(int event); 455 456 457 /***************************************/ 541 458 /* Endpoints lists helpers */ 542 459 /***************************************/ 460 461 struct fd_endpoint { 462 struct fd_list chain; /* link in cnf_endpoints list */ 463 464 union { 465 sSS ss; /* the socket information. List is always ordered by ss value (memcmp) -- see fd_ep_add_merge */ 466 sSA4 sin; 467 sSA6 sin6; 468 sSA sa; 469 }; 470 471 #define EP_FL_CONF (1 << 0) /* This endpoint is statically configured in a configuration file */ 472 #define EP_FL_DISC (1 << 1) /* This endpoint was resolved from the Diameter Identity or other DNS query */ 473 #define EP_FL_ADV (1 << 2) /* This endpoint was advertized in Diameter CER/CEA exchange */ 474 #define EP_FL_LL (1 << 3) /* Lower layer mechanism provided this endpoint */ 475 #define EP_FL_PRIMARY (1 << 4) /* This endpoint is primary in a multihomed SCTP association */ 476 uint32_t flags; /* Additional information about the endpoint */ 477 478 /* To add: a validity timestamp for DNS records ? How do we retrieve this lifetime from DNS ? */ 479 }; 543 480 544 481 int fd_ep_add_merge( struct fd_list * list, sSA * sa, socklen_t sl, uint32_t flags ); … … 553 490 /***************************************/ 554 491 492 struct fd_app { 493 struct fd_list chain; /* link in cnf_apps list. List ordered by appid. */ 494 struct { 495 unsigned auth : 1; 496 unsigned acct : 1; 497 unsigned common : 1; 498 } flags; 499 vendor_id_t vndid; /* if not 0, Vendor-Specific-App-Id AVP will be used */ 500 application_id_t appid; /* The identifier of the application */ 501 }; 502 555 503 int fd_app_merge(struct fd_list * list, application_id_t aid, vendor_id_t vid, int auth, int acct); 556 504 int fd_app_find_common(struct fd_list * target, struct fd_list * reference);
Note: See TracChangeset
for help on using the changeset viewer.