-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathAddrType.h
More file actions
executable file
·39 lines (32 loc) · 868 Bytes
/
Copy pathAddrType.h
File metadata and controls
executable file
·39 lines (32 loc) · 868 Bytes
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
34
35
36
37
38
39
/**************************************************************
* Copyright (c) 2010-2013, Dynamic Network Services, Inc.
* Jake Montgomery (jmontgomery@dyn.com) & Tom Daly (tom@dyn.com)
* Distributed under the FreeBSD License - see LICENSE
***************************************************************/
#pragma once
struct Addr
{
enum Type
{
Invalid,
IPv4,
IPv6
};
/**
* Returns IPv4, IPv6 or <Unknown>
*
* @param type
*
* @return const char*
*/
static const char* TypeToString(Addr::Type type);
/**
* Converts an address family to a Addr::Type
*/
static Addr::Type FamilyToType(int af);
/**
* Converts a Addr::Type to an address family.
*/
static int TypeToFamily(Addr::Type type);
inline static Addr::Type TypeFromBytesLen(size_t len) { return len == 4 ? IPv4 : len == 16 ? IPv6 : Invalid;}
};