Browse code

* fixed win32 non-ipv6 build

JuanJo Ciarlante authored on 2009/09/20 01:33:40
Showing 4 changed files
... ...
@@ -214,8 +214,10 @@ buf_printf (struct buffer *buf, const char *format, ...)
214 214
   return ret;
215 215
 }
216 216
 
217
-void buf_puts(struct buffer *buf, const char *str)
217
+bool
218
+buf_puts(struct buffer *buf, const char *str)
218 219
 {
220
+  int ret = false;
219 221
   uint8_t *ptr = BEND (buf);
220 222
   int cap = buf_forward_capacity (buf);
221 223
   if (cap > 0)
... ...
@@ -223,7 +225,9 @@ void buf_puts(struct buffer *buf, const char *str)
223 223
       strncpynt ((char *)ptr,str, cap);
224 224
       *(buf->data + buf->capacity - 1) = 0; /* windows vsnprintf needs this */
225 225
       buf->len += (int) strlen ((char *)ptr);
226
+      ret = true;
226 227
     }
228
+  return ret;
227 229
 }
228 230
  
229 231
 
... ...
@@ -277,6 +277,11 @@ bool buf_printf (struct buffer *buf, const char *format, ...)
277 277
     ;
278 278
 
279 279
 /*
280
+ * puts append to a buffer with overflow check
281
+ */
282
+bool buf_puts (struct buffer *buf, const char *str);
283
+
284
+/*
280 285
  * Like snprintf but guarantees null termination for size > 0
281 286
  */
282 287
 int openvpn_snprintf(char *str, size_t size, const char *format, ...)
... ...
@@ -1173,7 +1173,7 @@ openvpn_connect (socket_descriptor_t sd,
1173 1173
 	}
1174 1174
     }
1175 1175
 #else
1176
-  status = connect (sd, (struct sockaddr *) &remote->sa, sizeof (remote->sa));
1176
+  status = connect (sd, &remote->addr.sa, af_addr_size(remote->addr.sa.sa_family));
1177 1177
   if (status)
1178 1178
     status = openvpn_errno_socket ();
1179 1179
 #endif
... ...
@@ -2515,9 +2515,9 @@ void
2515 2515
 setenv_sockaddr (struct env_set *es, const char *name_prefix, const struct openvpn_sockaddr *addr, const bool flags)
2516 2516
 {
2517 2517
   char name_buf[256];
2518
-  char buf[128];
2519 2518
 
2520 2519
 #ifdef USE_PF_INET6
2520
+  char buf[128];
2521 2521
   switch(addr->addr.sa.sa_family)
2522 2522
     {
2523 2523
     case AF_INET:
... ...
@@ -2582,7 +2582,7 @@ struct proto_names {
2582 2582
   const char *display_form;
2583 2583
   bool	is_dgram;
2584 2584
   bool	is_net;
2585
-  sa_family_t proto_af;
2585
+  unsigned short proto_af;
2586 2586
 };
2587 2587
 
2588 2588
 /* Indexed by PROTO_x */
... ...
@@ -2629,7 +2629,7 @@ proto_is_tcp(int proto)
2629 2629
   return (!proto_names[proto].is_dgram)&&proto_names[proto].is_net;
2630 2630
 }
2631 2631
 
2632
-sa_family_t 
2632
+unsigned short 
2633 2633
 proto_sa_family(int proto)
2634 2634
 {
2635 2635
   if (proto < 0 || proto >= PROTO_N)
... ...
@@ -2679,7 +2679,9 @@ proto2ascii_all (struct gc_arena *gc)
2679 2679
 int
2680 2680
 addr_guess_family(int proto, const char *name) 
2681 2681
 {
2682
-  sa_family_t ret;
2682
+#ifdef USE_PF_INET6
2683
+  unsigned short ret;
2684
+#endif
2683 2685
   if (proto)
2684 2686
     {
2685 2687
       return proto_sa_family(proto);	/* already stamped */
... ...
@@ -3270,10 +3272,10 @@ socket_finalize (SOCKET s,
3270 3270
 	{
3271 3271
 	  if (io->addrlen != sizeof (io->addr))
3272 3272
 	    bad_address_length (io->addrlen, sizeof (io->addr));
3273
-	  from->dest.addr.sa = io->addr;
3273
+	  from->dest.addr.in4 = io->addr;
3274 3274
 	}
3275 3275
       else
3276
-	CLEAR (from->dest.addr.sa);
3276
+	CLEAR (from->dest.addr);
3277 3277
     }
3278 3278
   
3279 3279
   if (buf)
... ...
@@ -591,6 +591,7 @@ addr_defined_ipi (const struct link_socket_actual *lsa)
591 591
 #else
592 592
   ASSERT(0);
593 593
 #endif
594
+  return false;
594 595
 }
595 596
 
596 597
 static inline bool
... ...
@@ -702,7 +703,7 @@ addr_inet4or6(struct sockaddr *addr)
702 702
 
703 703
 int addr_guess_family(int proto, const char *name);
704 704
 static inline int
705
-af_addr_size(sa_family_t af)
705
+af_addr_size(unsigned short af)
706 706
 {
707 707
 #if defined(USE_PF_INET6) || defined (USE_PF_UNIX)
708 708
    switch(af) {