Haka: modules/protocol/ipv4/haka/cnx.h Source File

Haka

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

cnx.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #ifndef HAKA_PROTO_IPV4_CNX_H
6 #define HAKA_PROTO_IPV4_CNX_H
7
8 #include <haka/types.h>
9 #include <haka/ipv4.h>
10 #include <haka/lua/ref.h>
11 #include <haka/lua/object.h>
12
13 #define CNX_DIR_IN 0
14 #define CNX_DIR_OUT 1
15 #define CNX_DIR_CNT 2
16
17 struct cnx_table;
18
19 struct cnx_stats {
20 size_t packets;
21 size_t bytes;
22 };
23
24 struct cnx_key {
25 ipv4addr srcip;
26 ipv4addr dstip;
27 uint16 srcport;
28 uint16 dstport;
29 };
30
31 struct cnx {
32 struct lua_object lua_object;
33 struct cnx_key key;
34 struct cnx_stats stats[CNX_DIR_CNT];
35 bool dropped;
36 struct lua_ref lua_priv;
37 uint32 id;
38 void *priv;
39 };
40
41 struct cnx_table *cnx_table_new(void (*cnx_release)(struct cnx *, bool));
42 void cnx_table_release(struct cnx_table *table);
43 bool cnx_foreach(struct cnx_table *table, bool include_dropped, bool (*callback)(void *data, struct cnx *, int index), void *data);
44
45 struct cnx *cnx_new(struct cnx_table *table, struct cnx_key *key);
46 struct cnx *cnx_get(struct cnx_table *table, struct cnx_key *key, int *direction, bool *dropped);
47 struct cnx *cnx_get_byid(struct cnx_table *table, uint32 id);
48
49 void cnx_close(struct cnx *cnx);
50 void cnx_drop(struct cnx *cnx);
51 void cnx_update_stat(struct cnx *cnx, int direction, size_t size);
52
53 #endif /* HAKA_PROTO_IPV4_CNX_H */
types.h
ipv4addr
uint32 ipv4addr
Definition: ipv4-addr.h:25
uint16
unsigned HAKA_16BIT_TYPE uint16
Definition: types.h:28
uint32
unsigned HAKA_32BIT_TYPE uint32
Definition: types.h:29
ipv4.h