Navigation



Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/fD.h

    r20 r29  
    152152enum {
    153153        /* Dump all info about this peer in the debug log */
    154          FDEVP_DUMP_ALL = 2000
     154         FDEVP_DUMP_ALL = 1500
    155155       
    156156        /* request to terminate this peer : disconnect, requeue all messages */
    157157        ,FDEVP_TERMINATE
    158158       
    159         /* A message was received in the peer */
    160         ,FDEVP_MSG_INCOMING
     159        /* A connection object has received a message. (data contains the buffer) */
     160        ,FDEVP_CNX_MSG_RECV
     161                         
     162        /* A connection object has encountered an error (disconnected). */
     163        ,FDEVP_CNX_ERROR
     164       
     165        /* Endpoints of a connection have been changed (multihomed SCTP). */
     166        ,FDEVP_CNX_EP_CHANGE
     167       
     168        /* A new connection has been established (data contains the appropriate info) */
     169        ,FDEVP_CNX_INCOMING
    161170       
    162171        /* The PSM state is expired */
    163172        ,FDEVP_PSM_TIMEOUT
     173       
    164174};
    165175const char * fd_pev_str(int event);
    166176#define CHECK_EVENT( _e ) \
    167177        (((int)(_e) >= FDEVP_DUMP_ALL) && ((int)(_e) <= FDEVP_PSM_TIMEOUT))
     178
     179/* The data structure for FDEVP_CNX_INCOMING events */
     180struct cnx_incoming {
     181        struct msg      * cer;          /* the CER message received on this connection */
     182        struct cnxctx   * cnx;          /* The connection context */
     183        int               validate;     /* The peer is new, it must be validated (by an extension) or error CEA to be sent */
     184};
    168185
    169186/* Structure to store a sent request */
     
    173190};
    174191
    175 /* The connection context structure */
    176 struct cnxctx {
    177         int             cc_socket;      /* The socket object of the connection -- <=0 if no socket is created */
    178        
    179         struct fifo   **cc_events;      /* Location of the events list to send connection events */
    180        
    181         int             cc_proto;       /* IPPROTO_TCP or IPPROTO_SCTP */
    182         int             cc_tls;         /* Is TLS already started ? */
    183        
    184         uint16_t        cc_port;        /* Remote port of the connection, when we are client */
    185         struct fd_list  cc_ep_remote;   /* The remote address(es) of the connection */
    186         struct fd_list  cc_ep_local;    /* The local address(es) of the connection */
    187        
    188         /* If cc_proto == SCTP */
    189         struct  {
    190                 int             str_out;/* Out streams */
    191                 int             str_in; /* In streams */
    192                 int             pairs;  /* max number of pairs ( = min(in, out)) */
    193                 int             next;   /* # of stream the next message will be sent to */
    194         }               cc_sctp_para;
    195        
    196         /* If cc_tls == true */
    197         struct {
    198                 int                              mode;          /* GNUTLS_CLIENT / GNUTLS_SERVER */
    199                 gnutls_session_t                 session;       /* Session object (stream #0 in case of SCTP) */
    200         }               cc_tls_para;
    201        
    202         /* If both conditions */
    203         struct {
    204                 gnutls_session_t                *res_sessions;  /* Sessions of other pairs of streams, resumed from the first */
    205                 /* Buffers, threads, ... */
    206         }               cc_sctp_tls_para;
    207 };
    208192
    209193/* Functions */
    210 int fd_peer_fini();
     194int  fd_peer_fini();
    211195void fd_peer_dump_list(int details);
    212196void fd_peer_dump(struct fd_peer * peer, int details);
    213 int fd_peer_alloc(struct fd_peer ** ptr);
    214 int fd_peer_free(struct fd_peer ** ptr);
     197int  fd_peer_alloc(struct fd_peer ** ptr);
     198int  fd_peer_free(struct fd_peer ** ptr);
     199int fd_peer_handle_newCER( struct msg ** cer, struct cnxctx ** cnx );
    215200/* fd_peer_add declared in freeDiameter.h */
     201int fd_peer_validate( struct fd_peer * peer );
    216202
    217203/* Peer expiry */
     
    221207
    222208/* Peer state machine */
    223 int fd_psm_start();
    224 int fd_psm_begin(struct fd_peer * peer );
    225 int fd_psm_terminate(struct fd_peer * peer );
     209int  fd_psm_start();
     210int  fd_psm_begin(struct fd_peer * peer );
     211int  fd_psm_terminate(struct fd_peer * peer );
    226212void fd_psm_abord(struct fd_peer * peer );
    227213
    228214/* Server sockets */
    229215void fd_servers_dump();
    230 int fd_servers_start();
    231 void fd_servers_stop();
    232 
    233 /* Connection contexts */
    234 struct cnxctx * fd_cnx_init(int sock, int proto);
    235 int fd_cnx_handshake(struct cnxctx * conn, int mode);
    236 
    237 /* SCTP */
    238 #ifndef DISABLE_SCTP
    239 int fd_sctp_create_bind_server( int * socket, uint16_t port );
    240 int fd_sctp_get_str_info( int socket, int *in, int *out );
    241 
    242 #endif /* DISABLE_SCTP */
    243 
     216int  fd_servers_start();
     217int  fd_servers_stop();
     218
     219/* Connection contexts -- there are also definitions in cnxctx.h for the relevant files */
     220struct cnxctx * fd_cnx_serv_tcp(uint16_t port, int family, struct fd_endpoint * ep);
     221struct cnxctx * fd_cnx_serv_sctp(uint16_t port, struct fd_list * ep_list);
     222int             fd_cnx_serv_listen(struct cnxctx * conn);
     223struct cnxctx * fd_cnx_serv_accept(struct cnxctx * serv);
     224struct cnxctx * fd_cnx_cli_connect_tcp(sSA * sa, socklen_t addrlen);
     225struct cnxctx * fd_cnx_cli_connect_sctp(int no_ip6, uint16_t port, struct fd_list * list);
     226int             fd_cnx_start_clear(struct cnxctx * conn, int loop);
     227int             fd_cnx_handshake(struct cnxctx * conn, int mode, char * priority, void * alt_creds);
     228char *          fd_cnx_getid(struct cnxctx * conn);
     229int             fd_cnx_getproto(struct cnxctx * conn);
     230int             fd_cnx_getTLS(struct cnxctx * conn);
     231int             fd_cnx_getcred(struct cnxctx * conn, const gnutls_datum_t **cert_list, unsigned int *cert_list_size);
     232int             fd_cnx_getendpoints(struct cnxctx * conn, struct fd_list * local, struct fd_list * remote);
     233char *          fd_cnx_getremoteid(struct cnxctx * conn);
     234int             fd_cnx_receive(struct cnxctx * conn, struct timespec * timeout, unsigned char **buf, size_t * len);
     235int             fd_cnx_recv_setaltfifo(struct cnxctx * conn, struct fifo * alt_fifo); /* send FDEVP_CNX_MSG_RECV event to the fifo list */
     236int             fd_cnx_send(struct cnxctx * conn, unsigned char * buf, size_t len);
     237void            fd_cnx_destroy(struct cnxctx * conn);
    244238
    245239
Note: See TracChangeset for help on using the changeset viewer.