diff options
Diffstat (limited to 'core/network.h')
-rw-r--r-- | core/network.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/network.h b/core/network.h index d3c39333..7c95d84d 100644 --- a/core/network.h +++ b/core/network.h | |||
@@ -94,6 +94,11 @@ typedef struct { | |||
94 | #endif | 94 | #endif |
95 | } ADDR; | 95 | } ADDR; |
96 | 96 | ||
97 | /* Function to receive data, ip and port of sender is put into ip_port | ||
98 | the packet data into data | ||
99 | the packet length into length. */ | ||
100 | typedef int (*packet_handler_callback)(IP_Port ip_port, uint8_t *data, uint32_t len); | ||
101 | |||
97 | /* returns current time in milleseconds since the epoch. */ | 102 | /* returns current time in milleseconds since the epoch. */ |
98 | uint64_t current_time(void); | 103 | uint64_t current_time(void); |
99 | 104 | ||
@@ -106,10 +111,11 @@ uint32_t random_int(void); | |||
106 | /* Function to send packet(data) of length length to ip_port */ | 111 | /* Function to send packet(data) of length length to ip_port */ |
107 | int sendpacket(IP_Port ip_port, uint8_t *data, uint32_t length); | 112 | int sendpacket(IP_Port ip_port, uint8_t *data, uint32_t length); |
108 | 113 | ||
109 | /* Function to receive data, ip and port of sender is put into ip_port | 114 | /* Function to call when packet beginning with byte is received */ |
110 | the packet data into data | 115 | void networking_registerhandler(uint8_t byte, packet_handler_callback cb); |
111 | the packet length into length. */ | 116 | |
112 | int receivepacket(IP_Port *ip_port, uint8_t *data, uint32_t *length); | 117 | /* call this several times a second */ |
118 | void networking_poll(); | ||
113 | 119 | ||
114 | /* initialize networking | 120 | /* initialize networking |
115 | bind to ip and port | 121 | bind to ip and port |