diff options
Diffstat (limited to 'toxcore/network.h')
-rw-r--r-- | toxcore/network.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/toxcore/network.h b/toxcore/network.h index 9991c4a4..2a0b5560 100644 --- a/toxcore/network.h +++ b/toxcore/network.h | |||
@@ -86,9 +86,19 @@ typedef union { | |||
86 | uint8_t uint8[4]; | 86 | uint8_t uint8[4]; |
87 | uint16_t uint16[2]; | 87 | uint16_t uint16[2]; |
88 | uint32_t uint32; | 88 | uint32_t uint32; |
89 | in_addr_t in_addr; | 89 | struct in_addr in_addr; |
90 | } IP4; | 90 | } IP4; |
91 | 91 | ||
92 | typedef struct in6_addr IP6; | ||
93 | |||
94 | typedef struct { | ||
95 | sa_family_t family; | ||
96 | union { | ||
97 | IP4 ip4; | ||
98 | IP6 ip6; | ||
99 | }; | ||
100 | } IPAny; | ||
101 | |||
92 | typedef union { | 102 | typedef union { |
93 | struct { | 103 | struct { |
94 | IP4 ip; | 104 | IP4 ip; |
@@ -109,6 +119,15 @@ typedef struct { | |||
109 | #endif | 119 | #endif |
110 | } ADDR; | 120 | } ADDR; |
111 | 121 | ||
122 | /* | ||
123 | * addr_resolve_or_parse_ip | ||
124 | * resolves string into an IP address | ||
125 | * | ||
126 | * to->family MUST be set (AF_UNSPEC, AF_INET, AF_INET6) | ||
127 | * returns 1 on success, 0 on failure | ||
128 | */ | ||
129 | int addr_resolve_or_parse_ip(const char *address, IPAny *to); | ||
130 | |||
112 | /* Function to receive data, ip and port of sender is put into ip_port. | 131 | /* Function to receive data, ip and port of sender is put into ip_port. |
113 | * Packet data is put into data. | 132 | * Packet data is put into data. |
114 | * Packet length is put into length. | 133 | * Packet length is put into length. |
@@ -161,5 +180,4 @@ Networking_Core *new_networking(IP4 ip, uint16_t port); | |||
161 | /* Function to cleanup networking stuff (doesn't do much right now). */ | 180 | /* Function to cleanup networking stuff (doesn't do much right now). */ |
162 | void kill_networking(Networking_Core *net); | 181 | void kill_networking(Networking_Core *net); |
163 | 182 | ||
164 | |||
165 | #endif | 183 | #endif |