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