summaryrefslogtreecommitdiff
path: root/toxcore/network.h
diff options
context:
space:
mode:
authorCoren[m] <Break@Ocean>2013-09-09 14:53:27 +0200
committerCoren[m] <Break@Ocean>2013-09-09 14:53:27 +0200
commit55214aa041f2cc0305d290ff7dfd9e3e2f5e0bde (patch)
treef8a632cc3b559989d945a6f021ade3d1a919eabf /toxcore/network.h
parent29d777ef67bc964229722db073a2abdd1eb737b6 (diff)
network.*:
- IP4: changed in_addr_t to struct in_addr for compatibility reasons - IP6: added - IPAny: added - addr_resolve_or_parse_ip(): converts a string into an IPAny
Diffstat (limited to 'toxcore/network.h')
-rw-r--r--toxcore/network.h22
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
92typedef struct in6_addr IP6;
93
94typedef struct {
95 sa_family_t family;
96 union {
97 IP4 ip4;
98 IP6 ip6;
99 };
100} IPAny;
101
92typedef union { 102typedef 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 */
129int 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). */
162void kill_networking(Networking_Core *net); 181void kill_networking(Networking_Core *net);
163 182
164
165#endif 183#endif