blob: ac8964d77bed79a0b8faf5eaa4399262c224cbee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever.
$id$ */
#ifndef OT_IP_H__
#define OT_IP_H__
#include <stddef.h>
#include <string.h>
#include "trackerlogic.h"
/* opentracker holds every address as sixteen bytes, writing IPv4 as the v4
mapped form of RFC 4291 section 2.5.5.2. */
extern const char ip_v4mapped_prefix[12];
static inline int ip_is_v4mapped(const void *ip) { return !memcmp(ip, ip_v4mapped_prefix, sizeof(ip_v4mapped_prefix)); }
/* Read an address and return how many characters it took, or zero if src
does not start with one. A plain IPv4 address is accepted and stored in
its v4 mapped form.
The count lets the caller carry on where the address ended, which is how
"address:port" and "address/bits" are read. */
size_t ip_scan(const char *src, ot_ip6 ip);
/* Write an address and return how many characters it took. Nothing is
terminated, so a caller may keep appending. A v4 mapped address is written
as the plain dotted quad rather than "::ffff:1.2.3.4". */
size_t ip_format(char *dest, const ot_ip6 ip);
#endif
|