Haka: include/haka/packet.h Source File

Haka

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

packet.h
Go to the documentation of this file.
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
10 #ifndef HAKA_PACKET_H
11 #define HAKA_PACKET_H
12
13 #include <stddef.h>
14 #include <haka/types.h>
15 #include <haka/time.h>
16 #include <haka/time.h>
17 #include <haka/thread.h>
18 #include <haka/vbuffer.h>
19 #include <haka/lua/object.h>
20 #include <haka/lua/ref.h>
21
22
24 struct packet {
25 struct lua_object lua_object;
26 atomic_t ref;
27 struct vbuffer payload;
28 struct lua_ref userdata;
29 };
30
32 struct packet_module_state;
33 struct engine_thread;
39 enum packet_status {
40 STATUS_NORMAL,
41 STATUS_FORGED,
42 STATUS_SENT,
43 };
44
48 bool packet_init(struct packet_module_state *state);
49
53 void packet_addref(struct packet *pkt);
54
58 bool packet_release(struct packet *pkt);
59
63 struct packet *packet_new(size_t size);
64
68 const struct time *packet_timestamp(struct packet *pkt);
69
73 uint64 packet_id(struct packet *pkt);
74
78 struct vbuffer *packet_payload(struct packet *pkt);
79
83 const char *packet_dissector(struct packet *pkt);
84
88 void packet_drop(struct packet *pkt);
89
93 void packet_accept(struct packet *pkt);
94
99 bool packet_send(struct packet *pkt);
100
104 int packet_receive(struct engine_thread *engine, struct packet **pkt);
105
109 size_t packet_mtu(struct packet *pkt);
110
114 enum packet_status packet_state(struct packet *pkt);
115
119 enum packet_mode {
120 MODE_NORMAL,
121 MODE_PASSTHROUGH,
122 };
123
127 enum packet_mode packet_mode();
128
129 extern struct time_realm network_time;
130
131 #endif /* HAKA_PACKET_H */
packet_accept
void packet_accept(struct packet *pkt)
Definition: packet.c:165
packet_receive
int packet_receive(struct engine_thread *engine, struct packet **pkt)
Definition: packet.c:115
types.h
MODE_PASSTHROUGH
Definition: packet.h:121
vbuffer
Definition: vbuffer.h:64
time.h
uint64
unsigned HAKA_64BIT_TYPE uint64
Definition: types.h:30
packet_mode
packet_mode
Definition: packet.h:119
packet_timestamp
const struct time * packet_timestamp(struct packet *pkt)
Definition: packet.c:272
packet_addref
void packet_addref(struct packet *pkt)
Definition: packet.c:184
packet_payload
struct vbuffer * packet_payload(struct packet *pkt)
Definition: packet.c:109
MODE_NORMAL
Definition: packet.h:120
packet_id
uint64 packet_id(struct packet *pkt)
Definition: packet.c:279
packet
Definition: packet.h:24
packet_mtu
size_t packet_mtu(struct packet *pkt)
Definition: packet.c:265
STATUS_NORMAL
Definition: packet.h:40
packet_new
struct packet * packet_new(size_t size)
Definition: packet.c:205
STATUS_SENT
Definition: packet.h:42
packet_send
bool packet_send(struct packet *pkt)
Definition: packet.c:225
atomic_t
volatile uint32 atomic_t
Definition: thread.h:267
packet_release
bool packet_release(struct packet *pkt)
Definition: packet.c:190
packet_drop
void packet_drop(struct packet *pkt)
Definition: packet.c:150
time_realm
Definition: timer.h:27
packet_dissector
const char * packet_dissector(struct packet *pkt)
Definition: packet.c:102
packet_state
enum packet_status packet_state(struct packet *pkt)
Definition: packet.c:258
time
Definition: time.h:21
packet_init
bool packet_init(struct packet_module_state *state)
Definition: packet.c:89
packet_status
packet_status
Definition: packet.h:39
STATUS_FORGED
Definition: packet.h:41