-
Notifications
You must be signed in to change notification settings - Fork 30
/
ipaddr.h
51 lines (42 loc) · 1 KB
/
ipaddr.h
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
41
42
43
44
45
46
47
48
49
50
/*-
* xnumon - monitor macOS for malicious activity
* https://www.roe.ch/xnumon
*
* Copyright (c) 2017-2019, Daniel Roethlisberger <daniel@roe.ch>.
* All rights reserved.
*
* Licensed under the Open Software License version 3.0.
*/
#ifndef IPADDR_H
#define IPADDR_H
#include "attrib.h"
#include <stdbool.h>
#include <sys/socket.h>
#include <netinet/in.h>
#ifndef IPPROTO_TCP
#define IPPROTO_TCP 6
#endif
#ifndef IPPROTO_UDP
#define IPPROTO_UDP 17
#endif
#ifndef IPPROTO_SCTP
#define IPPROTO_SCTP 132
#endif
typedef struct ipaddr {
sa_family_t family;
union {
/* AF_INET */
uint32_t ev_addr;
struct in_addr sin_addr;
/* AF_INET6 */
uint32_t ev6_addr[4];
struct in6_addr sin6_addr;
};
} ipaddr_t;
const char * ipaddrtoa(ipaddr_t *, const char *) NONNULL(1) WUNRES;
bool ipaddr_is_localhost(ipaddr_t *) NONNULL(1) WUNRES;
#define ipaddr_is_empty(PIPADDR) ((PIPADDR)->family == 0)
const char * protocoltoa(int) WUNRES;
const char * domaintoa(int) WUNRES;
const char * typetoa(int) WUNRES;
#endif