diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-11-01 22:48:25 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:05:11 -0500 |
commit | 284349482f5293a9a23d0f72d7c2aab46b55843b (patch) | |
tree | 6f96931afb18ea841983a2895b62c97fed9f77b7 /source4/lib/util_sock.c | |
parent | 9f14afa12c11d02a49f4f310c3f8d834ce8a835d (diff) | |
download | samba-284349482f5293a9a23d0f72d7c2aab46b55843b.tar.gz samba-284349482f5293a9a23d0f72d7c2aab46b55843b.tar.bz2 samba-284349482f5293a9a23d0f72d7c2aab46b55843b.zip |
r3443: the next stage in the include files re-organisation.
I have created the include/system/ directory, which will contain the
wrappers for the system includes for logical subsystems. So far I have
created include/system/kerberos.h and include/system/network.h, which
contain all the system includes for kerberos code and networking code.
These are the included in subsystems that need kerberos or networking
respectively.
Note that this method avoids the mess of #ifdef HAVE_XXX_H in every C
file, instead each C module includes the include/system/XXX.h file for
the logical system support it needs, and the details are kept isolated
in include/system/
This patch also creates a "struct ipv4_addr" which replaces "struct
in_addr" in our code. That avoids every C file needing to import all
the system networking headers.
(This used to be commit 2e25c71853f8996f73755277e448e7d670810349)
Diffstat (limited to 'source4/lib/util_sock.c')
-rw-r--r-- | source4/lib/util_sock.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/source4/lib/util_sock.c b/source4/lib/util_sock.c index 0cb23920f1..dbd71b58b6 100644 --- a/source4/lib/util_sock.c +++ b/source4/lib/util_sock.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "system/network.h" /**************************************************************************** @@ -156,7 +157,7 @@ void set_socket_options(int fd, const char *options) ****************************************************************************/ ssize_t read_udp_socket(int fd, char *buf, size_t len, - struct in_addr *from_addr, int *from_port) + struct ipv4_addr *from_addr, int *from_port) { ssize_t ret; struct sockaddr_in sock; @@ -169,7 +170,7 @@ ssize_t read_udp_socket(int fd, char *buf, size_t len, } if (from_addr) { - *from_addr = sock.sin_addr; + from_addr->s_addr = sock.sin_addr.s_addr; } if (from_port) { *from_port = ntohs(sock.sin_port); @@ -337,7 +338,7 @@ int open_socket_in( int type, int port, int dlevel, uint32_t socket_addr, BOOL r /**************************************************************************** create an outgoing socket. timeout is in milliseconds. **************************************************************************/ -int open_socket_out(int type, struct in_addr *addr, int port, int timeout) +int open_socket_out(int type, struct ipv4_addr *addr, int port, int timeout) { struct sockaddr_in sock_out; int res,ret; @@ -360,7 +361,7 @@ int open_socket_out(int type, struct in_addr *addr, int port, int timeout) /* set it non-blocking */ set_blocking(res,False); - DEBUG(3,("Connecting to %s at port %d\n",inet_ntoa(*addr),port)); + DEBUG(3,("Connecting to %s at port %d\n", sys_inet_ntoa(*addr),port)); /* and connect it to the destination */ connect_again: @@ -375,7 +376,7 @@ connect_again: if (ret < 0 && (errno == EINPROGRESS || errno == EALREADY || errno == EAGAIN)) { - DEBUG(1,("timeout connecting to %s:%d\n",inet_ntoa(*addr),port)); + DEBUG(1,("timeout connecting to %s:%d\n", sys_inet_ntoa(*addr),port)); close(res); return -1; } @@ -389,7 +390,7 @@ connect_again: if (ret < 0) { DEBUG(2,("error connecting to %s:%d (%s)\n", - inet_ntoa(*addr),port,strerror(errno))); + sys_inet_ntoa(*addr),port,strerror(errno))); close(res); return -1; } @@ -408,7 +409,7 @@ int open_udp_socket(const char *host, int port) int type = SOCK_DGRAM; struct sockaddr_in sock_out; int res; - struct in_addr addr; + struct ipv4_addr addr; TALLOC_CTX *mem_ctx; mem_ctx = talloc_init("open_udp_socket"); @@ -442,7 +443,7 @@ int open_udp_socket(const char *host, int port) matchname - determine if host name matches IP address. Used to confirm a hostname lookup to prevent spoof attacks ******************************************************************/ -static BOOL matchname(char *remotehost, struct in_addr addr) +static BOOL matchname(char *remotehost, struct ipv4_addr addr) { struct hostent *hp; int i; @@ -480,7 +481,7 @@ static BOOL matchname(char *remotehost, struct in_addr addr) */ DEBUG(0,("host name/address mismatch: %s != %s\n", - inet_ntoa(addr), hp->h_name)); + sys_inet_ntoa(addr), hp->h_name)); return False; } @@ -492,7 +493,7 @@ char *get_socket_name(TALLOC_CTX *mem_ctx, int fd, BOOL force_lookup) { char *name_buf; struct hostent *hp; - struct in_addr addr; + struct ipv4_addr addr; char *p; /* reverse lookups can be *very* expensive, and in many |