Quellcode durchsuchen

fixed ipv6 in -r

wangyu- vor 7 Jahren
Ursprung
Commit
d4564b6249
2 geänderte Dateien mit 6 neuen und 5 gelöschten Zeilen
  1. 3 3
      common.cpp
  2. 3 2
      common.h

+ 3 - 3
common.cpp

@@ -881,7 +881,7 @@ int create_fifo(char * file)
 #endif
 }
 
-
+/*
 int new_listen_socket(int &fd,u32_t ip,int port)
 {
 	fd =socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
@@ -939,7 +939,7 @@ int new_connected_socket(int &fd,u32_t ip,int port)
 	}
 	return 0;
 }
-
+*/
 int new_listen_socket2(int &fd,address_t &addr)
 {
 	fd =socket(addr.get_type(), SOCK_DGRAM, IPPROTO_UDP);
@@ -960,7 +960,7 @@ int new_listen_socket2(int &fd,address_t &addr)
 }
 int new_connected_socket2(int &fd,address_t &addr)
 {
-	fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+	fd = socket(addr.get_type(), SOCK_DGRAM, IPPROTO_UDP);
 	if (fd < 0) {
 		mylog(log_warn, "[%s]create udp_fd error\n", addr.get_str());
 		return -1;

+ 3 - 2
common.h

@@ -233,6 +233,7 @@ struct address_t  //TODO scope id
 	{
 		memset(&inner,0,sizeof(inner));
 	}
+	/*
 	int from_ip_port(u32_t  ip, int port)
 	{
 		clear();
@@ -240,7 +241,7 @@ struct address_t  //TODO scope id
 		inner.ipv4.sin_port=htons(port);
 		inner.ipv4.sin_addr.s_addr=ip;
 		return 0;
-	}
+	}*/
 
 	int from_ip_port_new(int type, void *  ip, int port)
 	{
@@ -253,7 +254,7 @@ struct address_t  //TODO scope id
 		}
 		else if(type==AF_INET6)
 		{
-			inner.ipv6.sin6_family=AF_INET;
+			inner.ipv6.sin6_family=AF_INET6;
 			inner.ipv6.sin6_port=htons(port);
 			inner.ipv6.sin6_addr=*((in6_addr*)ip);
 		}