radsecproxy-1.6.5.
[radsecproxy.git] / util.h
1 /*
2  * Copyright (C) 2006-2008 Stig Venaas <venaas@uninett.no>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  */
8
9 #include <sys/socket.h>
10 #include <netdb.h>
11
12 #define SOCKADDR_SIZE(addr) ((addr).ss_family == AF_INET ?      \
13                              sizeof(struct sockaddr_in) :       \
14                              sizeof(struct sockaddr_in6))
15
16 #define SOCKADDRP_SIZE(addr) ((addr)->sa_family == AF_INET ?    \
17                               sizeof(struct sockaddr_in) :      \
18                               sizeof(struct sockaddr_in6))
19
20 char *stringcopy(const char *s, int len);
21 char *addr2string(struct sockaddr *addr);
22 struct sockaddr *addr_copy(struct sockaddr *in);
23 void port_set(struct sockaddr *sa, uint16_t port);
24
25 void printfchars(char *prefixfmt, char *prefix, char *charfmt, char *chars, int len);
26 void disable_DF_bit(int socket, struct addrinfo *res);
27 int bindtoaddr(struct addrinfo *addrinfo, int family, int reuse, int v6only);
28 int connecttcp(struct addrinfo *addrinfo, struct addrinfo *src, uint16_t timeout);
29
30
31 /* Local Variables: */
32 /* c-file-style: "stroustrup" */
33 /* End: */