summaryrefslogtreecommitdiff
path: root/cesar/cp2/conn/conn.h
blob: 2964920f1f03fe825bbfb0e76e85f44061a7a218 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#ifndef cp2_conn_conn_h
#define cp2_conn_conn_h
/* Cesar project {{{
 *
 * Copyright (C) 2008 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \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, u8 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, u8 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 */