diff options
Diffstat (limited to 'core/network.h')
-rw-r--r-- | core/network.h | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/core/network.h b/core/network.h index eaf12003..a59d7c38 100644 --- a/core/network.h +++ b/core/network.h | |||
@@ -69,23 +69,20 @@ extern "C" { | |||
69 | 69 | ||
70 | #define MAX_UDP_PACKET_SIZE 65507 | 70 | #define MAX_UDP_PACKET_SIZE 65507 |
71 | 71 | ||
72 | typedef union | 72 | typedef union { |
73 | { | ||
74 | uint8_t c[4]; | 73 | uint8_t c[4]; |
75 | uint16_t s[2]; | 74 | uint16_t s[2]; |
76 | uint32_t i; | 75 | uint32_t i; |
77 | }IP; | 76 | } IP; |
78 | 77 | ||
79 | typedef struct | 78 | typedef struct { |
80 | { | ||
81 | IP ip; | 79 | IP ip; |
82 | uint16_t port; | 80 | uint16_t port; |
83 | /* not used for anything right now */ | 81 | /* not used for anything right now */ |
84 | uint16_t padding; | 82 | uint16_t padding; |
85 | }IP_Port; | 83 | } IP_Port; |
86 | 84 | ||
87 | typedef struct | 85 | typedef struct { |
88 | { | ||
89 | int16_t family; | 86 | int16_t family; |
90 | uint16_t port; | 87 | uint16_t port; |
91 | IP ip; | 88 | IP ip; |
@@ -93,7 +90,7 @@ typedef struct | |||
93 | #ifdef ENABLE_IPV6 | 90 | #ifdef ENABLE_IPV6 |
94 | uint8_t zeroes2[12]; | 91 | uint8_t zeroes2[12]; |
95 | #endif | 92 | #endif |
96 | }ADDR; | 93 | } ADDR; |
97 | 94 | ||
98 | /* returns current time in milleseconds since the epoch. */ | 95 | /* returns current time in milleseconds since the epoch. */ |
99 | uint64_t current_time(); | 96 | uint64_t current_time(); |
@@ -105,12 +102,12 @@ uint32_t random_int(); | |||
105 | /* Basic network functions: */ | 102 | /* Basic network functions: */ |
106 | 103 | ||
107 | /* Function to send packet(data) of length length to ip_port */ | 104 | /* Function to send packet(data) of length length to ip_port */ |
108 | int sendpacket(IP_Port ip_port, uint8_t * data, uint32_t length); | 105 | int sendpacket(IP_Port ip_port, uint8_t *data, uint32_t length); |
109 | 106 | ||
110 | /* Function to receive data, ip and port of sender is put into ip_port | 107 | /* Function to receive data, ip and port of sender is put into ip_port |
111 | the packet data into data | 108 | the packet data into data |
112 | the packet length into length. */ | 109 | the packet length into length. */ |
113 | int receivepacket(IP_Port * ip_port, uint8_t * data, uint32_t * length); | 110 | int receivepacket(IP_Port *ip_port, uint8_t *data, uint32_t *length); |
114 | 111 | ||
115 | /* initialize networking | 112 | /* initialize networking |
116 | bind to ip and port | 113 | bind to ip and port |
@@ -118,7 +115,7 @@ int receivepacket(IP_Port * ip_port, uint8_t * data, uint32_t * length); | |||
118 | port is in host byte order (this means don't worry about it) | 115 | port is in host byte order (this means don't worry about it) |
119 | returns 0 if no problems | 116 | returns 0 if no problems |
120 | returns -1 if there were problems */ | 117 | returns -1 if there were problems */ |
121 | int init_networking(IP ip ,uint16_t port); | 118 | int init_networking(IP ip, uint16_t port); |
122 | 119 | ||
123 | /* function to cleanup networking stuff(doesn't do much right now) */ | 120 | /* function to cleanup networking stuff(doesn't do much right now) */ |
124 | void shutdown_networking(); | 121 | void shutdown_networking(); |