/* This software was written by Dirk Engling It is considered beerware. Prost. Skol. Cheers or whatever. $id$ */ #ifndef OT_IP_H__ #define OT_IP_H__ #include #include #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