forked from dyninc/OpenBFDD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddrType.cpp
executable file
·40 lines (36 loc) · 915 Bytes
/
AddrType.cpp
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
40
/**************************************************************
* Copyright (c) 2010-2013, Dynamic Network Services, Inc.
* Jake Montgomery ([email protected]) & Tom Daly ([email protected])
* Distributed under the FreeBSD License - see LICENSE
***************************************************************/
#include "common.h"
#include "AddrType.h"
#include <sys/socket.h>
using namespace std;
Addr::Type Addr::FamilyToType(int af)
{
if (af == AF_INET)
return Addr::IPv4;
else if (af == AF_INET6)
return Addr::IPv6;
else
return Addr::Invalid;
}
int Addr::TypeToFamily(Addr::Type type)
{
if (type == Addr::IPv4)
return AF_INET;
else if (type == Addr::IPv6)
return AF_INET6;
else
return AF_UNSPEC;
}
const char* Addr::TypeToString(Addr::Type type)
{
if (type == Addr::IPv4)
return "IPv4";
else if (type == Addr::IPv6)
return "IPv6";
else
return "<unknown>";
}