summaryrefslogtreecommitdiffstats
path: root/src/types.h
diff options
context:
space:
mode:
authorSimon Rettberg2017-10-28 14:56:58 +0200
committerSimon Rettberg2017-10-28 14:56:58 +0200
commitc8c62246f84b5d9d4a496097f043696e2d9ba0bb (patch)
tree27a896f6677791ef8087fa44b1aab7cb2071d774 /src/types.h
parent[SERVER] Add function to parse x-www-form-urlencoded strings (diff)
downloaddnbd3-c8c62246f84b5d9d4a496097f043696e2d9ba0bb.tar.gz
dnbd3-c8c62246f84b5d9d4a496097f043696e2d9ba0bb.tar.xz
dnbd3-c8c62246f84b5d9d4a496097f043696e2d9ba0bb.zip
[*] Introduce constants for IPv4/6 in dnbd3_host_t
AF_INET luckily was "2" on all platforms checked, so no problems there with interoperation, but AF_INET6 is different between Linux, BSD, Windows and possibly others, so map back and forth between AF_INET/AF_INET6 and HOST_IP4/HOST_IP6 to fix this.
Diffstat (limited to 'src/types.h')
-rw-r--r--src/types.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/types.h b/src/types.h
index 9f9e744..313e907 100644
--- a/src/types.h
+++ b/src/types.h
@@ -98,12 +98,18 @@ static const uint16_t dnbd3_packet_magic = (0x73) | (0x72 << 8);
#error "Unknown Endianness"
#endif
+typedef uint8_t dnbd3_af;
+
+static const dnbd3_af HOST_NONE = (dnbd3_af)0;
+static const dnbd3_af HOST_IP4 = (dnbd3_af)2;
+static const dnbd3_af HOST_IP6 = (dnbd3_af)10;
+
#pragma pack(1)
typedef struct dnbd3_host_t
{
uint8_t addr[16]; // 16byte (network representation, so it can be directly passed to socket functions)
uint16_t port; // 2byte (network representation, so it can be directly passed to socket functions)
- uint8_t type; // 1byte (ip version. AF_INET or AF_INET6. 0 means this struct is empty and should be ignored)
+ dnbd3_af type; // 1byte (ip version. HOST_IP4 or HOST_IP6. 0 means this struct is empty and should be ignored)
} dnbd3_host_t;
#pragma pack(0)