Andrei Pelinescu-Onciul 23 rokov pred
rodič
commit
535315280f
5 zmenil súbory, kde vykonal 21 pridanie a 10 odobranie
  1. 4 4
      ip_addr.h
  2. 4 1
      main.c
  3. 2 1
      resolve.c
  4. 3 3
      test/stateless.cfg
  5. 8 1
      udp_server.c

+ 4 - 4
ip_addr.h

@@ -176,7 +176,7 @@ static inline int init_su( union sockaddr_union* su,
 #ifdef USE_IPV6
 	case	AF_INET6:
 		memcpy(&su->sin6.sin6_addr, ip->u.addr, ip->len); 
-		#ifdef FreeBSD
+		#ifdef __FreeBSD__
 			su->sin6.sin6_len=sizeof(struct sockaddr_in6);
 		#endif
 		su->sin6.sin6_port=port;
@@ -184,7 +184,7 @@ static inline int init_su( union sockaddr_union* su,
 #endif
 	case AF_INET:
 		memcpy(&su->sin.sin_addr, ip->u.addr, ip->len);
-		#ifdef FreeBSD
+		#ifdef __FreeBSD__
 			su->sin.sin_len=sizeof(struct sockaddr_in);
 		#endif
 		su->sin.sin_port=port;
@@ -212,7 +212,7 @@ static inline int hostent2su( union sockaddr_union* su,
 #ifdef USE_IPV6
 	case	AF_INET6:
 		memcpy(&su->sin6.sin6_addr, he->h_addr_list[idx], he->h_length);
-		#ifdef FreeBSD
+		#ifdef __FreeBSD__
 			su->sin6.sin6_len=sizeof(struct sockaddr_in6);
 		#endif
 		su->sin6.sin6_port=port;
@@ -220,7 +220,7 @@ static inline int hostent2su( union sockaddr_union* su,
 #endif
 	case AF_INET:
 		memcpy(&su->sin.sin_addr, he->h_addr_list[idx], he->h_length);
-		#ifdef FreeBSD
+		#ifdef __FreeBSD__
 			su->sin.sin_len=sizeof(struct sockaddr_in);
 		#endif
 		su->sin.sin_port=port;

+ 4 - 1
main.c

@@ -704,7 +704,10 @@ int add_interfaces(char* if_name, int family, unsigned short port)
 	char* tmp;
 	struct ip_addr addr;
 	int ret;
-	
+
+#ifdef __FreeBSD__
+	#define MAX(a,b) ( ((a)>(b))?(a):(b))
+#endif
 	/* ipv4 or ipv6 only*/
 	s=socket(family, SOCK_DGRAM, 0);
 	ret=-1;

+ 2 - 1
resolve.c

@@ -1,7 +1,8 @@
 /* $Id$*/
 
-/* #include <arpa/nameser.h> -- included from resolve.h*/
+#include <sys/types.h>
 #include <netinet/in.h>
+#include <arpa/nameser.h>
 #include <resolv.h>
 #include <string.h>
 

+ 3 - 3
test/stateless.cfg

@@ -12,13 +12,13 @@ log_stderror=yes # (cmd line: -E)
 #log_stderror=no	# (cmd line: -E)
 
 
-children=10
+children=2
 check_via=no     # (cmd. line: -v)
 dns=off           # (cmd. line: -r)
 rev_dns=off      # (cmd. line: -R)
 #port=5070
-listen=10.0.0.179 lo	dorian
-listen=eth0
+#listen=10.0.0.179 lo	dorian
+#listen=eth0
 #listen=127.0.0.1
 #listen=192.168.57.33
 #listen=192.168.57.72

+ 8 - 1
udp_server.c

@@ -113,6 +113,7 @@ int probe_max_receive_buffer( int udp_sock )
 int udp_init(struct socket_info* sock_info)
 {
 	union sockaddr_union* addr;
+	int sock_len;
 	int optval;
 
 
@@ -157,8 +158,14 @@ int udp_init(struct socket_info* sock_info)
 
 
 	if ( probe_max_receive_buffer(sock_info->socket)==-1) goto error;
+#ifdef __FreeBSD__
+	sock_len=addr->s.sa_len;
+#else
+	sock_len=sizeof(union sockaddr_union);
+#endif
+	
 
-	if (bind(sock_info->socket,  &addr->s, sizeof(union sockaddr_union))==-1){
+	if (bind(sock_info->socket,  &addr->s, sock_len)==-1){
 		LOG(L_ERR, "ERROR: udp_init: bind(%x, %p, %d) on %s: %s\n",
 				sock_info->socket, &addr->s, 
 				sizeof(union sockaddr_union),