Changeset f1f7b5e for lib


Ignore:
Timestamp:
2010-07-24T22:50:23Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
8b01217
Parents:
2945c6f
Message:

Take the local address from the IM/IRC connection when setting up a listening
socket for file transfers.

Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/ftutil.c

    r2945c6f rf1f7b5e  
    3636 * Creates a listening socket and returns it in saddr_ptr.
    3737 */
    38 int ft_listen( struct sockaddr_storage *saddr_ptr, char *host, char *port, int for_bitlbee_client, char **errptr )
     38int ft_listen( struct sockaddr_storage *saddr_ptr, char *host, char *port, int copy_fd, int for_bitlbee_client, char **errptr )
    3939{
    4040        int fd, gret, saddrlen;
     
    8383                }
    8484        }
     85        else if( copy_fd >= 0 && getsockname( copy_fd, (struct sockaddr*) &saddrs, &ssize ) == 0 &&
     86                 ( saddrs.ss_family == AF_INET || saddrs.ss_family == AF_INET6 ) &&
     87                 getnameinfo( (struct sockaddr*) &saddrs, ssize, host, HOST_NAME_MAX,
     88                              NULL, 0, NI_NUMERICHOST ) == 0 )
     89        {
     90                /* We just took our local address on copy_fd, which is likely to be a
     91                   sensible address from which we can do a file transfer now - the
     92                   most sensible we can get easily. */
     93        }
    8594        else
    8695        {
     
    117126        }
    118127
     128        ssize = sizeof( struct sockaddr_storage );
    119129        ASSERTSOCKOP( getsockname( fd, ( struct sockaddr *)saddr, &ssize ), "Getting socket name" );
    120130
  • lib/ftutil.h

    r2945c6f rf1f7b5e  
    3838/* This function should be used with care. host should be AT LEAST a
    3939   char[HOST_NAME_MAX+1] and port AT LEAST a char[6]. */
    40 int ft_listen( struct sockaddr_storage *saddr_ptr, char *host, char *port, int for_bitlbee_client, char **errptr );
     40int ft_listen( struct sockaddr_storage *saddr_ptr, char *host, char *port, int copy_fd, int for_bitlbee_client, char **errptr );
Note: See TracChangeset for help on using the changeset viewer.