Changeset e4d6271
- Timestamp:
- 2005-12-27T14:39:32Z (19 years ago)
- Branches:
- master
- Children:
- e62762b
- Parents:
- 238f828
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.c
r238f828 re4d6271 68 68 int bitlbee_daemon_init() 69 69 { 70 #ifdef IPV6 71 struct sockaddr_in6 listen_addr; 72 #else 70 73 struct sockaddr_in listen_addr; 74 #endif 71 75 int i; 72 76 GIOChannel *ch; … … 75 79 log_link( LOGLVL_WARNING, LOGOUTPUT_SYSLOG ); 76 80 77 global.listen_socket = socket( AF_INET , SOCK_STREAM, 0 );81 global.listen_socket = socket( AF_INETx, SOCK_STREAM, 0 ); 78 82 if( global.listen_socket == -1 ) 79 83 { … … 81 85 return( -1 ); 82 86 } 83 listen_addr.sin_family = AF_INET; 87 88 #ifdef IPV6 89 listen_addr.sin6_family = AF_INETx; 90 listen_addr.sin6_port = htons( global.conf->port ); 91 i = inet_pton( AF_INETx, global.conf->iface, &listen_addr.sin6_addr ); 92 #else 93 listen_addr.sin_family = AF_INETx; 84 94 listen_addr.sin_port = htons( global.conf->port ); 85 listen_addr.sin_addr.s_addr = inet_addr( global.conf->iface ); 86 87 i = bind( global.listen_socket, (struct sockaddr *) &listen_addr, sizeof( struct sockaddr ) ); 95 i = inet_pton( AF_INETx, global.conf->iface, &listen_addr.sin_addr ); 96 #endif 97 98 if( i != 1 ) 99 { 100 log_message( LOGLVL_ERROR, "Couldn't parse address `%s'", global.conf->iface ); 101 return( -1 ); 102 } 103 104 i = bind( global.listen_socket, (struct sockaddr *) &listen_addr, sizeof( listen_addr ) ); 88 105 if( i == -1 ) 89 106 { -
irc.c
r238f828 re4d6271 40 40 irc_t *irc_new( int fd ) 41 41 { 42 irc_t *irc = g_new0( irc_t, 1 ); 43 42 irc_t *irc; 43 struct hostent *peer; 44 unsigned int i; 45 char buf[128]; 46 #ifdef IPV6 47 struct sockaddr_in6 sock[1]; 48 #else 44 49 struct sockaddr_in sock[1]; 45 #ifdef IPV646 struct sockaddr_in6 sock6[1];47 50 #endif 48 struct hostent *peer;49 unsigned int i, j;51 52 irc = g_new0( irc_t, 1 ); 50 53 51 54 irc->fd = fd; … … 71 74 72 75 i = sizeof( *sock ); 73 #ifdef IPV6 74 j = sizeof( *sock6 ); 75 #endif 76 76 77 if( global.conf->hostname ) 77 78 irc->myhost = g_strdup( global.conf->hostname ); 78 else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET ) 79 { 80 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) ) 79 #ifdef IPV6 80 else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin6_family == AF_INETx ) 81 { 82 if( ( peer = gethostbyaddr( (char*) &sock->sin6_addr, sizeof( sock->sin6_addr ), AF_INETx ) ) ) 81 83 irc->myhost = g_strdup( peer->h_name ); 82 } 83 #ifdef IPV6 84 else if( getsockname( irc->fd, (struct sockaddr*) sock6, &j ) == 0 && sock6->sin6_family == AF_INET6 ) 85 { 86 if( ( peer = gethostbyaddr( (char*) &sock6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6 ) ) ) 84 else if( inet_ntop( AF_INETx, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL ) 85 irc->myhost = g_strdup( buf ); 86 } 87 #else 88 else if( getsockname( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INETx ) 89 { 90 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INETx ) ) ) 87 91 irc->myhost = g_strdup( peer->h_name ); 92 else if( inet_ntop( AF_INETx, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL ) 93 irc->myhost = g_strdup( buf ); 88 94 } 89 95 #endif … … 91 97 i = sizeof( *sock ); 92 98 #ifdef IPV6 93 j = sizeof( *sock6 ); 94 #endif 95 if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INET ) 96 { 97 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INET ) ) ) 99 if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin6_family == AF_INETx ) 100 { 101 if( ( peer = gethostbyaddr( (char*) &sock->sin6_addr, sizeof( sock->sin6_addr ), AF_INETx ) ) ) 98 102 irc->host = g_strdup( peer->h_name ); 99 } 100 #ifdef IPV6 101 else if( getpeername( irc->fd, (struct sockaddr*) sock6, &j ) == 0 && sock6->sin6_family == AF_INET6 ) 102 { 103 if( ( peer = gethostbyaddr( (char*) &sock6->sin6_addr, sizeof( sock6->sin6_addr ), AF_INET6 ) ) ) 103 else if( inet_ntop( AF_INETx, &sock->sin6_addr, buf, sizeof( buf ) - 1 ) != NULL ) 104 irc->host = g_strdup( buf ); 105 } 106 #else 107 if( getpeername( irc->fd, (struct sockaddr*) sock, &i ) == 0 && sock->sin_family == AF_INETx ) 108 { 109 if( ( peer = gethostbyaddr( (char*) &sock->sin_addr, sizeof( sock->sin_addr ), AF_INETx ) ) ) 104 110 irc->host = g_strdup( peer->h_name ); 111 else if( inet_ntop( AF_INETx, &sock->sin_addr, buf, sizeof( buf ) - 1 ) != NULL ) 112 irc->host = g_strdup( buf ); 105 113 } 106 114 #endif -
protocols/http_client.c
r238f828 re4d6271 27 27 #include <stdio.h> 28 28 29 #include "sock.h"30 29 #include "http_client.h" 31 30 #include "url.h" 31 #include "sock.h" 32 32 33 33 -
protocols/oscar/oscar.c
r238f828 re4d6271 21 21 */ 22 22 23 #include "sock.h"24 23 #include <errno.h> 25 24 #include <ctype.h> … … 33 32 #include "bitlbee.h" 34 33 #include "proxy.h" 34 #include "sock.h" 35 35 36 36 #include "aim.h" -
sock.h
r238f828 re4d6271 1 1 #include <errno.h> 2 2 #include <fcntl.h> 3 4 /* To cut down on the ifdef stuff a little bit in other places */ 5 #ifdef IPV6 6 #define AF_INETx AF_INET6 7 #else 8 #define AF_INETx AF_INET 9 #endif 3 10 4 11 #ifndef _WIN32
Note: See TracChangeset
for help on using the changeset viewer.