Navigation



Ignore:
Timestamp:
Sep 25, 2009, 4:12:08 PM (15 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Added some extensions and functions in the daemon

File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/freeDiameter.h

    r8 r10  
    4343/* Structure to hold the configuration of the freeDiameter daemon */
    4444struct fd_config {
    45         int              eyec;          /* Eye catcher: EYEC_CONFIG */
    46         char            *conf_file;     /* Configuration file to parse, default is DEFAULT_CONF_FILE */
    47        
    48         char            *diam_id;       /* Diameter Identity of the local peer (FQDN -- UTF-8) */
    49         size_t           diam_id_len;   /* length of the previous string */
    50         char            *diam_realm;    /* Diameter realm of the local peer, default to realm part of diam_id */
    51         size_t           diam_realm_len;/* length of the previous string */
    52        
    53         uint16_t         loc_port;      /* the local port for legacy Diameter (default: 3868) in host byte order */
    54         uint16_t         loc_port_tls;  /* the local port for Diameter/TLS (default: 3869) in host byte order */
    55         uint16_t         loc_sctp_str;  /* default max number of streams for SCTP associations (def: 30) */
    56         struct fd_list   loc_endpoints; /* the local endpoints to bind the server to. list of struct fd_endpoint. default is empty (bind all) */
     45        int              cnf_eyec;      /* Eye catcher: EYEC_CONFIG */
     46                        #define EYEC_CONFIG     0xC011F16
     47       
     48        char            *cnf_file;      /* Configuration file to parse, default is DEFAULT_CONF_FILE */
     49       
     50        char            *cnf_diamid;    /* Diameter Identity of the local peer (FQDN -- UTF-8) */
     51        size_t           cnf_diamid_len;        /* length of the previous string */
     52        char            *cnf_diamrlm;   /* Diameter realm of the local peer, default to realm part of diam_id */
     53        size_t           cnf_diamrlm_len;/* length of the previous string */
     54       
     55        unsigned int     cnf_timer_tc;  /* The value in seconds of the default Tc timer */
     56        unsigned int     cnf_timer_tw;  /* The value in seconds of the default Tw timer */
     57       
     58        uint16_t         cnf_port;      /* the local port for legacy Diameter (default: 3868) in host byte order */
     59        uint16_t         cnf_port_tls;  /* the local port for Diameter/TLS (default: 3869) in host byte order */
     60        uint16_t         cnf_sctp_str;  /* default max number of streams for SCTP associations (def: 30) */
     61        struct fd_list   cnf_endpoints; /* the local endpoints to bind the server to. list of struct fd_endpoint. default is empty (bind all) */
     62        struct fd_list   cnf_apps;      /* Applications locally supported (except relay, see flags). Use fd_disp_app_support to add one. list of struct fd_app. */
    5763        struct {
     64                unsigned no_fwd : 1;    /* the peer does not relay messages (0xffffff app id) */
    5865                unsigned no_ip4 : 1;    /* disable IP */
    5966                unsigned no_ip6 : 1;    /* disable IPv6 */
     
    6269                unsigned pr_tcp : 1;    /* prefer TCP over SCTP */
    6370                unsigned tls_alg: 1;    /* TLS algorithm for initiated cnx. 0: separate port. 1: inband-security (old) */
    64                 unsigned no_fwd : 1;    /* the peer does not relay messages (0xffffff app id) */
    65         }                flags;
    66        
    67         unsigned int     timer_tc;      /* The value in seconds of the default Tc timer */
    68         unsigned int     timer_tw;      /* The value in seconds of the default Tw timer */
    69        
    70         uint32_t         or_state_id;   /* The value to use in Origin-State-Id, default to random value */
    71         struct dictionary *g_dict;      /* pointer to the global dictionary */
    72         struct fifo       *g_fifo_main; /* FIFO queue of events in the daemon main (struct fd_event items) */
    73 };
    74 
    75 #define EYEC_CONFIG     0xC011F16
    76 
    77 /* The pointer to access the global configuration, initalized in main */
    78 extern struct fd_config *fd_g_config;
     71        }                cnf_flags;
     72       
     73        uint32_t         cnf_orstateid; /* The value to use in Origin-State-Id, default to random value */
     74        struct dictionary *cnf_dict;    /* pointer to the global dictionary */
     75        struct fifo       *cnf_main_ev; /* events for the daemon's main (struct fd_event items) */
     76};
     77extern struct fd_config *fd_g_config; /* The pointer to access the global configuration, initalized in main */
    7978
    8079/* Endpoints */
    8180struct fd_endpoint {
    82         struct fd_list  chain;  /* link in loc_endpoints list */
     81        struct fd_list  chain;  /* link in cnf_endpoints list */
    8382        sSS             ss;     /* the socket information. */
    8483};
     84
     85/* Applications */
     86struct fd_app {
     87        struct fd_list   chain; /* link in cnf_apps list. List ordered by appid. */
     88        struct {
     89                unsigned auth   : 1;
     90                unsigned acct   : 1;
     91                unsigned common : 1;
     92        }                flags;
     93        vendor_id_t      vndid; /* if not 0, Vendor-Specific-App-Id AVP will be used */
     94        application_id_t appid; /* The identifier of the application */
     95};
     96       
    8597
    8698/* Events */
     
    90102};
    91103
    92 /* send an event */
    93104static __inline__ int fd_event_send(struct fifo *queue, int code, void * data)
    94105{
     
    100111        return 0;
    101112}
    102 /* receive an event */
    103113static __inline__ int fd_event_get(struct fifo *queue, int *code, void ** data)
    104114{
     
    112122        return 0;
    113123}
     124
     125/* Events codespace for fd_g_config->cnf_main_ev */
     126enum {
     127        FDEV_TERMINATE = 1000,  /* request to terminate */
     128        FDEV_DUMP_DICT,         /* Dump the content of the dictionary */
     129        FDEV_DUMP_EXT,          /* Dump state of extensions */
     130        FDEV_DUMP_QUEUES,       /* Dump the message queues */
     131        FDEV_DUMP_CONFIG,       /* Dump the configuration */
     132        FDEV_DUMP_PEERS         /* Dump the list of peers */
     133};
     134
     135
     136
     137/***************************************/
     138/*   Peers information                 */
     139/***************************************/
     140
     141/* States of a peer */
     142enum peer_state {
     143        /* Stable states */
     144        STATE_DISABLED = 1,     /* No connexion must be attempted / only this state means that the peer PSM thread is not running */
     145        STATE_OPEN,             /* Connexion established */
     146       
     147        /* Peer state machine */
     148        STATE_CLOSED,           /* No connection established, will re-attempt after TcTimer. */
     149        STATE_CLOSING,          /* the connection is being shutdown (DPR/DPA in progress) */
     150        STATE_WAITCNXACK,       /* Attempting to establish transport-level connection */
     151        STATE_WAITCNXACK_ELEC,  /* Received a CER from this same peer on an incoming connection (other peer object), while we were waiting for cnx ack */
     152        STATE_WAITCEA,          /* Connection established, CER sent, waiting for CEA */
     153        /* STATE_WAITRETURNS_ELEC, */   /* This state is not stable and therefore deprecated:
     154                                   We have sent a CER on our initiated connection, and received a CER from the remote peer on another connection. Election.
     155                                   If we win the election, we must disconnect the initiated connection and send a CEA on the other => we go to OPEN state.
     156                                   If we lose, we disconnect the other connection (receiver) and fallback to WAITCEA state. */
     157       
     158        /* Failover state machine */
     159        STATE_SUSPECT,          /* A DWR was sent and not answered within TwTime. Failover in progress. */
     160        STATE_REOPEN            /* Connection has been re-established, waiting for 3 DWR/DWA exchanges before putting back to service */
     161};
     162extern char *peer_state_str[];
     163
     164/* Information about a remote peer, used both for query and for creating a new entry */
     165struct peer_info {
     166       
     167        /* This information is always there */
     168        char * pi_diamid;       /* UTF-8, \0 terminated. The Diameter Identity of the remote peer */
     169        char * pi_realm;        /* idem, its realm. */
     170       
     171        /* Flags */
     172        struct {
     173                #define PI_PROT_DEFAULT 0       /* Use the default algorithm configured for the host */
     174                #define PI_PROT_TCP     1
     175                #define PI_PROT_SCTP    2
     176                unsigned        proto :2;
     177               
     178                #define PI_SEC_DEFAULT  0       /* The default behavior configured for the host */
     179                #define PI_SEC_NONE     1       /* Transparent security with this peer (IPsec) */
     180                #define PI_SEC_TLS_NEW  2       /* New TLS security (dedicated port protecting also CER/CEA) */
     181                #define PI_SEC_TLS_OLD  3       /* Old TLS security (inband on default port) */
     182                unsigned        sec :2;
     183               
     184                #define PI_EXP_DEFAULT  0
     185                #define PI_EXP_NONE     1       /* the peer entry does not expire */
     186                #define PI_EXP_INACTIVE 2       /* the peer entry expires after pi_lft seconds without activity */
     187                #define PI_EXP_LIFETIME 3       /* the peer SA information is destroyed after lft seconds (example: DNS timeout) */
     188                unsigned        exp :2;
     189               
     190                /* Following flags are read-only and received from remote peer */
     191                #define PI_INB_NONE     1       /* Remote peer advertised inband-sec-id 0 (None) */
     192                #define PI_INB_TLS      2       /* Remote peer advertised inband-sec-id 1 (TLS) */
     193                unsigned        inband :2;      /* This is only meaningful with pi_flags.sec == 3 */
     194               
     195                unsigned        relay :1;       /* The remote peer advertized the relay application */         
     196        } pi_flags;
     197       
     198        /* Additional parameters */
     199        uint32_t        pi_lft;         /* lifetime of entry without activity (except watchdogs) (see pi_flags.exp definition) */
     200        uint16_t        pi_streams;     /* number of streams for SCTP. 0 = default */
     201        uint16_t        pi_port;        /* port to connect to. 0: default. */
     202        int             pi_tctimer;     /* use this value for TcTimer instead of global, if != 0 */
     203        int             pi_twtimer;     /* use this value for TwTimer instead of global, if != 0 */
     204       
     205        struct fd_list  pi_endpoints;   /* Endpoint(s) of the remote peer (discovered or advertized). list of struct fd_endpoint. DNS resolved if empty. */
     206       
     207        /* The remaining information is read-only, not used for peer creation */
     208        enum peer_state pi_state;
     209        uint32_t        pi_vendorid;    /* Content of the Vendor-Id AVP, or 0 by default */
     210        uint32_t        pi_orstate;     /* Origin-State-Id value */
     211        char *          pi_prodname;    /* copy of UTF-8 Product-Name AVP (\0 terminated) */
     212        uint32_t        pi_firmrev;     /* Content of the Firmware-Revision AVP */
     213        struct fd_list  pi_apps;        /* applications advertised by the remote peer, except relay (pi_flags.relay) */
     214};
     215
    114216
    115217/***************************************/
     
    158260 * PARAMETERS:
    159261 *  msg         : A msg object -- it must be an answer.
    160  *  dict        : dictionary to use for AVP definitions
    161262 *  rescode     : The name of the returned error code (ex: "DIAMETER_INVALID_AVP")
    162263 *  errormsg    : (optional) human-readable error message to put in Error-Message AVP
     
    173274 *  !0          : an error occurred.
    174275 */
    175 int fd_msg_rescode_set( struct msg * msg, struct dictionary * dict, char * rescode, char * errormsg, struct avp * optavp, int type_id );
    176 
    177 /* The following functions are used to achieve frequent operations on the messages */
    178 int fd_msg_add_origin ( struct msg * msg, struct dictionary * dict, int osi ); /* Add Origin-Host, Origin-Realm, (if osi) Origin-State-Id AVPS at the end of the message */
     276int fd_msg_rescode_set( struct msg * msg, char * rescode, char * errormsg, struct avp * optavp, int type_id );
     277
     278/* Add Origin-Host, Origin-Realm, (if osi) Origin-State-Id AVPS at the end of the message */
     279int fd_msg_add_origin ( struct msg * msg, int osi );
    179280
    180281
     
    184285/***************************************/
    185286
    186 enum {
    187         DISP_APP_AUTH   = 1,
    188         DISP_APP_ACCT   = 2
    189 };
    190287/*
    191288 * FUNCTION:    fd_disp_app_support
     
    194291 *  app         : The dictionary object corresponding to the Application.
    195292 *  vendor      : (Optional) the dictionary object of a Vendor to claim support in Vendor-Specific-Application-Id
    196  *  flags       : Combination of DISP_APP_* flags.
     293 *  auth        : Support auth app part.
     294 *  acct        : Support acct app part.
    197295 *
    198296 * DESCRIPTION:
     
    205303 *  EINVAL      : A parameter is invalid.
    206304 */
    207 int fd_disp_app_support ( struct dict_object * app, struct dict_object * vendor, int flags );
     305int fd_disp_app_support ( struct dict_object * app, struct dict_object * vendor, int auth, int acct );
    208306
    209307/* Note: if we want to support capabilities updates, we'll have to add possibility to remove an app as well... */
Note: See TracChangeset for help on using the changeset viewer.