-
Notifications
You must be signed in to change notification settings - Fork 2
/
ss_network.h
37 lines (32 loc) · 955 Bytes
/
ss_network.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
#ifndef _SS_NETWORK_H_
#define _SS_NETWORK_H_
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#if !defined(SA_LEN)
#define SA_LEN(sa) \
(((sa)->sa_family == AF_INET) ? \
sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6))
#endif
#if !defined(SS_LEN)
#define SS_LEN(ss) \
(((ss)->ss_family == AF_INET) ? \
sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6))
#endif
#if !defined(satosin)
#define satosin(sa) ((struct sockaddr_in *)(sa))
#endif
#if !defined(satosin6)
#define satosin6(sa) ((struct sockaddr_in6 *)(sa))
#endif
#if !defined(sstosa)
#define sstosa(ss) ((struct sockaddr *)(ss))
#endif
int resolve(struct sockaddr *, int, const char *, const char *, int);
int local4remote(struct sockaddr *, struct sockaddr_storage *);
double getdtime(void);
char *addr2char_r(struct sockaddr *, char *, int);
const char *addr2char(struct sockaddr *);
#endif