Skip to content

Commit 091c259

Browse files
committed
Updating documentation
1 parent cd54c34 commit 091c259

File tree

2 files changed

+47
-8
lines changed

2 files changed

+47
-8
lines changed

README.md

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ License: MIT
2525
- Comprehensive positive and negative tests
2626

2727

28+
# IPv4 Compatibility Mode
29+
30+
See test.c: test_api_use_loopback_const
31+
127.111.2.1
32+
uint16_t components[IPV6_NUM_COMPONENTS] = {
33+
0x7f6f,
34+
0x0201 }
35+
- Addresses can be constructed directly in code and support the full two-way functionality
36+
37+
# Building / Debugging
38+
39+
Full tracing can be enabled by running cmake -DPARSE_TRACE=1
40+
41+
2842
*ipv6_flag_t*
2943
===
3044

@@ -35,8 +49,8 @@ after parsing. Address components are assumed.
3549
typedef enum {
3650
IPV6_FLAG_HAS_PORT = 0x00000001, // the address specifies a port setting
3751
IPV6_FLAG_HAS_MASK = 0x00000002, // the address specifies a CIDR mask
38-
IPV6_FLAG_IPV4_EMBED = 0x00000002, // the address has an embedded IPv4 address in the last 32bits
39-
IPV6_FLAG_IPV4_COMPAT = 0x00000004, // the address is IPv4 compatible (1.2.3.4:5555)
52+
IPV6_FLAG_IPV4_EMBED = 0x00000004, // the address has an embedded IPv4 address in the last 32bits
53+
IPV6_FLAG_IPV4_COMPAT = 0x00000008, // the address is IPv4 compatible (1.2.3.4:5555)
4054
} ipv6_flag_t;
4155
~~~~
4256

@@ -51,6 +65,8 @@ e.g. little-endian x86 mahinces:
5165

5266
~~~~
5367
#define IPV6_NUM_COMPONENTS 8
68+
#define IPV4_NUM_COMPONENTS 2
69+
#define IPV4_EMBED_INDEX 6
5470
typedef struct {
5571
uint16_t components[IPV6_NUM_COMPONENTS];
5672
} ipv6_address_t;
@@ -75,6 +91,21 @@ typedef struct {
7591
} ipv6_address_full_t;
7692
~~~~
7793

94+
*ipv6_compare_t*
95+
===
96+
97+
Result of ipv6_compare of two addresses
98+
99+
~~~~
100+
typedef enum {
101+
IPV6_COMPARE_OK = 0,
102+
IPV6_COMPARE_FORMAT_MISMATCH, // address differ in their
103+
IPV6_COMPARE_MASK_MISMATCH, // the CIDR mask does not match
104+
IPV6_COMPARE_PORT_MISMATCH, // the port does not match
105+
IPV6_COMPARE_ADDRESS_MISMATCH, // address components do not match
106+
} ipv6_compare_t;
107+
~~~~
108+
78109
*ipv6_diag_event_t*
79110
===
80111

@@ -121,7 +152,7 @@ typedef struct {
121152
A diagnostic function that receives information from parsing the address
122153

123154
~~~~
124-
typedef void (*ipv6_diag_func_t )(
155+
typedef void (*ipv6_diag_func_t) (
125156
ipv6_diag_event_t event,
126157
const ipv6_diag_info_t* info,
127158
void* user_data);
@@ -174,10 +205,18 @@ char* IPV6_API_DECL(ipv6_to_str) (
174205
*ipv6_compare*
175206
===
176207

177-
Compare two addresses, 0 if equal, 1 if a greater, -1 if a lesser
208+
Compare two addresses, 0 (IPV6_COMPARE_OK) if equal, else ipv6_compare_result_t.
209+
210+
Use IPV6_FLAG_HAS_MASK, IPV6_FLAG_HAS_PORT in ignore_flags to
211+
ignore mask or port in comparisons.
212+
213+
IPv4 embed and IPv4 compatible addresses will be compared as
214+
equal if either IPV6_FLAG_IPV4_EMBED or IPV6_FLAG_IPV4_COMPAT
215+
flags are passed in ignore_flags.
178216

179217
~~~~
180218
int32_t IPV6_API_DECL(ipv6_compare) (
181219
const ipv6_address_full_t* a,
182-
const ipv6_address_full_t* b);
220+
const ipv6_address_full_t* b,
221+
uint32_t ignore_flags);
183222
~~~~

ipv6.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,14 @@ char* IPV6_API_DECL(ipv6_to_str) (
229229
// *ipv6_compare*
230230
// ===
231231
//
232-
// Compare two addresses, 0 if equal else ipv6_compare_result_t.
232+
// Compare two addresses, 0 (IPV6_COMPARE_OK) if equal, else ipv6_compare_result_t.
233233
//
234234
// Use IPV6_FLAG_HAS_MASK, IPV6_FLAG_HAS_PORT in ignore_flags to
235235
// ignore mask or port in comparisons.
236236
//
237237
// IPv4 embed and IPv4 compatible addresses will be compared as
238-
// equal if IPV6_FLAG_IPV4_EMBED or IPV6_FLAG_IPV4_COMPAT
239-
// is passed in ignore_flags.
238+
// equal if either IPV6_FLAG_IPV4_EMBED or IPV6_FLAG_IPV4_COMPAT
239+
// flags are passed in ignore_flags.
240240
//
241241
// ~~~~
242242
int32_t IPV6_API_DECL(ipv6_compare) (

0 commit comments

Comments
 (0)