00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _KLONE_ADDR_H_
00012 #define _KLONE_ADDR_H_
00013
00014 #include <u/libu.h>
00015
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019
00020 typedef struct addr_s
00021 {
00022 enum type_e { ADDR_IPV4, ADDR_IPV6, ADDR_UNIX } type;
00023 union
00024 {
00025 struct sockaddr_in sin;
00026 #ifndef NO_IPV6
00027 struct sockaddr_in6 sin6;
00028 #endif
00029 #ifndef NO_UNIXSOCK
00030 struct sockaddr_un sun;
00031 #endif
00032 } sa;
00033 } addr_t;
00034
00035 int addr_create(addr_t **pa);
00036 int addr_set_from_config(addr_t *a, u_config_t *c);
00037 int addr_set_from_sa(addr_t *a, struct sockaddr *sa, size_t sz);
00038 int addr_set(addr_t *a, const char *ip, int port);
00039 int addr_set_ipv4_ip(addr_t *a, const char *ip);
00040 int addr_set_ipv4_port(addr_t *a, int port);
00041 int addr_free(addr_t *a);
00042
00043 #ifdef __cplusplus
00044 }
00045 #endif
00046
00047 #endif