diff options
author | JuanJo Ciarlante <jjo@google.com> | 2009-09-19 18:33:40 +0200 |
---|---|---|
committer | JuanJo Ciarlante <juanjosec@gmail.com> | 2011-03-25 13:30:29 +0100 |
commit | 4d3df224e1210f732b84cf4273fb57993361d4ba (patch) | |
tree | 35c33c6e1fc7848361712450b8f156bd99a12d1a | |
parent | 387df51180cf9139abfbc33b141fd395a58633b5 (diff) | |
download | openvpn-4d3df224e1210f732b84cf4273fb57993361d4ba.tar.gz openvpn-4d3df224e1210f732b84cf4273fb57993361d4ba.tar.xz openvpn-4d3df224e1210f732b84cf4273fb57993361d4ba.zip |
* fixed win32 non-ipv6 build
-rw-r--r-- | buffer.c | 6 | ||||
-rw-r--r-- | buffer.h | 5 | ||||
-rw-r--r-- | socket.c | 16 | ||||
-rw-r--r-- | socket.h | 3 |
4 files changed, 21 insertions, 9 deletions
@@ -214,8 +214,10 @@ buf_printf (struct buffer *buf, const char *format, ...) return ret; } -void buf_puts(struct buffer *buf, const char *str) +bool +buf_puts(struct buffer *buf, const char *str) { + int ret = false; uint8_t *ptr = BEND (buf); int cap = buf_forward_capacity (buf); if (cap > 0) @@ -223,7 +225,9 @@ void buf_puts(struct buffer *buf, const char *str) strncpynt ((char *)ptr,str, cap); *(buf->data + buf->capacity - 1) = 0; /* windows vsnprintf needs this */ buf->len += (int) strlen ((char *)ptr); + ret = true; } + return ret; } @@ -277,6 +277,11 @@ bool buf_printf (struct buffer *buf, const char *format, ...) ; /* + * puts append to a buffer with overflow check + */ +bool buf_puts (struct buffer *buf, const char *str); + +/* * Like snprintf but guarantees null termination for size > 0 */ int openvpn_snprintf(char *str, size_t size, const char *format, ...) @@ -1173,7 +1173,7 @@ openvpn_connect (socket_descriptor_t sd, } } #else - status = connect (sd, (struct sockaddr *) &remote->sa, sizeof (remote->sa)); + status = connect (sd, &remote->addr.sa, af_addr_size(remote->addr.sa.sa_family)); if (status) status = openvpn_errno_socket (); #endif @@ -2515,9 +2515,9 @@ void setenv_sockaddr (struct env_set *es, const char *name_prefix, const struct openvpn_sockaddr *addr, const bool flags) { char name_buf[256]; - char buf[128]; #ifdef USE_PF_INET6 + char buf[128]; switch(addr->addr.sa.sa_family) { case AF_INET: @@ -2582,7 +2582,7 @@ struct proto_names { const char *display_form; bool is_dgram; bool is_net; - sa_family_t proto_af; + unsigned short proto_af; }; /* Indexed by PROTO_x */ @@ -2629,7 +2629,7 @@ proto_is_tcp(int proto) return (!proto_names[proto].is_dgram)&&proto_names[proto].is_net; } -sa_family_t +unsigned short proto_sa_family(int proto) { if (proto < 0 || proto >= PROTO_N) @@ -2679,7 +2679,9 @@ proto2ascii_all (struct gc_arena *gc) int addr_guess_family(int proto, const char *name) { - sa_family_t ret; +#ifdef USE_PF_INET6 + unsigned short ret; +#endif if (proto) { return proto_sa_family(proto); /* already stamped */ @@ -3270,10 +3272,10 @@ socket_finalize (SOCKET s, { if (io->addrlen != sizeof (io->addr)) bad_address_length (io->addrlen, sizeof (io->addr)); - from->dest.addr.sa = io->addr; + from->dest.addr.in4 = io->addr; } else - CLEAR (from->dest.addr.sa); + CLEAR (from->dest.addr); } if (buf) @@ -591,6 +591,7 @@ addr_defined_ipi (const struct link_socket_actual *lsa) #else ASSERT(0); #endif + return false; } static inline bool @@ -702,7 +703,7 @@ addr_inet4or6(struct sockaddr *addr) int addr_guess_family(int proto, const char *name); static inline int -af_addr_size(sa_family_t af) +af_addr_size(unsigned short af) { #if defined(USE_PF_INET6) || defined (USE_PF_UNIX) switch(af) { |