Navigation



Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/freeDiameter.h

    r25 r20  
    118118struct fd_endpoint {
    119119        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 ? */
     120        sSS             ss;     /* the socket information. List is always ordered by ss value (memcmp) */
     121        struct {
     122                unsigned conf : 1; /* This endpoint is statically configured in a configuration file */
     123                unsigned disc : 1; /* This endpoint was resolved from the Diameter Identity or other DNS query */
     124                unsigned adv  : 1; /* This endpoint was advertized in Diameter CER/CEA exchange */
     125                unsigned ll   : 1; /* Lower layer mechanism provided this endpoint */
     126               
     127                /* To add: a validity timestamp for DNS records ? How do we retrieve this lifetime from DNS ? */
     128
     129        }               meta;   /* Additional information about the endpoint */
    136130};
    137131
     
    152146struct fd_event {
    153147        int      code; /* codespace depends on the queue */
    154         size_t   size;
    155148        void    *data;
    156149};
    157150
    158 /* Daemon's codespace: 1000->1999 */
     151static __inline__ int fd_event_send(struct fifo *queue, int code, void * data)
     152{
     153        struct fd_event * ev;
     154        CHECK_MALLOC( ev = malloc(sizeof(struct fd_event)) );
     155        ev->code = code;
     156        ev->data = data;
     157        CHECK_FCT( fd_fifo_post(queue, &ev) );
     158        return 0;
     159}
     160static __inline__ int fd_event_get(struct fifo *queue, int *code, void ** data)
     161{
     162        struct fd_event * ev;
     163        CHECK_FCT( fd_fifo_get(queue, &ev) );
     164        if (code)
     165                *code = ev->code;
     166        if (data)
     167                *data = ev->data;
     168        free(ev);
     169        return 0;
     170}
     171
     172/* Events codespace for fd_g_config->cnf_main_ev */
    159173enum {
    160          FDEV_TERMINATE = 1000  /* request to terminate */
     174         FDEV_TERMINATE = 1000  /* request to terminate */
    161175        ,FDEV_DUMP_DICT         /* Dump the content of the dictionary */
    162176        ,FDEV_DUMP_EXT          /* Dump state of extensions */
     
    166180        ,FDEV_DUMP_PEERS        /* Dump the list of peers */
    167181};
    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 
    227182const char * fd_ev_str(int event); /* defined in freeDiameter/main.c */
    228183
     
    301256        /* Additional parameters */
    302257        uint32_t        pi_lft;         /* lifetime of this peer when inactive (see pi_flags.exp definition) */
     258        uint16_t        pi_streams;     /* number of streams for SCTP. 0 = default */
    303259        uint16_t        pi_port;        /* port to connect to. 0: default. */
    304260        int             pi_tctimer;     /* use this value for TcTimer instead of global, if != 0 */
     
    315271        struct fd_list  pi_apps;        /* applications advertised by the remote peer, except relay (pi_flags.relay) */
    316272        struct {
    317                 char                    *priority;      /* In case the default priority is not appropriate */
    318273                /* This is inspired from http://www.gnu.org/software/gnutls/manual/gnutls.html#ex_003ax509_002dinfo */
    319274                const gnutls_datum_t    *cert_list;     /* The (valid) credentials that the peer has presented */
     
    505460
    506461
    507 /***************************************/
    508 /*   Endpoints lists helpers           */
    509 /***************************************/
    510 
    511 int fd_ep_add_merge( struct fd_list * list, sSA * sa, socklen_t sl, uint32_t flags );
    512 int fd_ep_filter( struct fd_list * list, uint32_t flags );
    513 int fd_ep_clearflags( struct fd_list * list, uint32_t flags );
    514 
    515 
    516 
    517462#endif /* _FREEDIAMETER_H */
Note: See TracChangeset for help on using the changeset viewer.