#ifndef cp2_conn_conn_h #define cp2_conn_conn_h /* Cesar project {{{ * * Copyright (C) 2008 Spidcom * * <<>> * * }}} */ /** * \file cp_conn.h * \brief « brief description » * \ingroup « module » * * « long description » */ #include "cp2/cp.h" #include "cp2/conn/link.h" /* * Different type of a connection * */ enum cp_conn_type_t{ CP_CONN_TYPE_UNICAST, CP_CONN_TYPE_MULTICAST, CP_CONN_TYPE_BROADCAST, CP_CONN_TYPE_MULTIUNICAST, }; typedef enum cp_conn_type_t cp_conn_type_t; /* * Different state of a connection * */ enum cp_conn_state_t{ CP_CONN_STATE_IN, CP_CONN_STATE_OUT, CP_CONN_STATE_ADD, CP_CONN_STATE_REL_BW, CP_CONN_STATE_REL_NOR, CP_CONN_STATE_REL_REQ, CP_CONN_STATE_REL_CSPEC, CP_CONN_STATE_STAYOUT }; typedef enum cp_conn_state_t cp_conn_state_t; /** * Connection Specification */ struct cp_conn_cspec_t { /** CSPEC length in octet */ u16 cspec_len_oct; /** Forward CINFO */ cp_link_cinfo_t *f_cinfo; /** Reverse CINFO */ cp_link_cinfo_t *r_cinfo; /** Forward QMP */ cp_link_qmp_t *f_qmp; /** Reverse QMP */ cp_link_qmp_t *r_qmp; }; typedef struct cp_conn_cspec_t cp_conn_cspec_t; struct cp_conn_info_t { /** Connection identifier */ u16 cid; /** STEI */ u8 stei; /** DTEI */ u8 dtei; /** LID-F */ u8 lid_f; /** LID-R */ u8 lid_r; /** CSPEC */ cp_conn_cspec_t *cspec; }; typedef struct cp_conn_info_t cp_conn_info_t; /** * Structure of a connection. Add, delete, return a link. */ struct cp_conn_t { /** Connection Type */ cp_conn_type_t type; /** Connection information */ cp_conn_info_t *conn_info; /** Forward link id (global or local) */ cp_link_t *flink; /** Reverse link id (local or global) */ cp_link_t *rlink; /** connection state */ cp_conn_state_t conn_state; /** Request ID */ u8 request_id; /** expiration date of the connection used by the garbadge collector */ u16 expiration; /** Original Source Address */ mac_t osa; /** Original Destination Address */ mac_t oda; /** GLID */ u16 glid; /** list Node conn */ list_node_t node; }; typedef struct cp_conn_t cp_conn_t; /** * add a connection into the connection list * \param ctx Control plane context. * \param new_conn Connection to add into the list * */ void cp_conn_add_conn(cp_t *ctx, cp_conn_t *conn); /** * delete a connection from the connection list * \param ctx Control Plane context. * \param cid Connection identifier of the connection to delete * */ void cp_conn_del_conn (cp_t *ctx, u16 cid); /** * Give access to a connection * \param ctx Control plane context. * \param cid connection identifier of the targeted connection * \return the target connection * */ cp_conn_t* cp_conn_get_conn (cp_t *ctx, u16 cid); /** * Modify the caracteristics of a connection * \param ctx control plane context. * \param modified_conn Modified connection * */ void cp_conn_mod_conn (cp_t *ctx, cp_conn_t* modified_conn); /** * Garbage collector * \param ctx Control Plane context. * */ void cp_conn_garbage_conn (cp_conn_t *ctx); /** * Check the validity of a connection * \param ctx Control plane context * \param conn Connection to validate * \return the result of the test * */ u8 cp_conn_check_conn_validity (cp_t *ctx, cp_conn_t* conn); #endif /* cp_conn_h */