Haka
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;
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 
122 };
123 
127 enum packet_mode packet_mode();
128 
129 extern struct time_realm network_time;
130 
131 #endif /* HAKA_PACKET_H */
void packet_accept(struct packet *pkt)
Definition: packet.c:165
int packet_receive(struct engine_thread *engine, struct packet **pkt)
Definition: packet.c:115
Definition: packet.h:121
Definition: vbuffer.h:64
unsigned HAKA_64BIT_TYPE uint64
Definition: types.h:30
packet_mode
Definition: packet.h:119
const struct time * packet_timestamp(struct packet *pkt)
Definition: packet.c:272
void packet_addref(struct packet *pkt)
Definition: packet.c:184
struct vbuffer * packet_payload(struct packet *pkt)
Definition: packet.c:109
Definition: packet.h:120
uint64 packet_id(struct packet *pkt)
Definition: packet.c:279
Definition: packet.h:24
size_t packet_mtu(struct packet *pkt)
Definition: packet.c:265
Definition: packet.h:40
struct packet * packet_new(size_t size)
Definition: packet.c:205
Definition: packet.h:42
bool packet_send(struct packet *pkt)
Definition: packet.c:225
volatile uint32 atomic_t
Definition: thread.h:267
bool packet_release(struct packet *pkt)
Definition: packet.c:190
void packet_drop(struct packet *pkt)
Definition: packet.c:150
Definition: timer.h:27
const char * packet_dissector(struct packet *pkt)
Definition: packet.c:102
enum packet_status packet_state(struct packet *pkt)
Definition: packet.c:258
Definition: time.h:21
bool packet_init(struct packet_module_state *state)
Definition: packet.c:89
packet_status
Definition: packet.h:39
Definition: packet.h:41