-
Notifications
You must be signed in to change notification settings - Fork 133
/
inet.c
48 lines (43 loc) · 880 Bytes
/
inet.c
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
/*
inet.c
Date Created: Wed Feb 24 17:48:08 2010
Author: Simon Leinen <[email protected]>
*/
#include "config.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#include <string.h>
#include <errno.h>
#if STDC_HEADERS
# define bzero(b,n) memset(b,0,n)
#else
# include <strings.h>
#endif
#include "samplicator.h"
#include "inet.h"
void
init_hints_from_preferences (hints, ctx)
struct addrinfo *hints;
const struct samplicator_context *ctx;
{
bzero (hints, sizeof *hints);
hints->ai_flags = AI_PASSIVE|AI_ADDRCONFIG;
hints->ai_socktype = SOCK_DGRAM;
if (ctx->ipv4_only)
{
hints->ai_family = AF_INET;
}
else if (ctx->ipv6_only)
{
hints->ai_family = AF_INET6;
}
else
{
hints->ai_family = AF_UNSPEC;
}
}