@@ -55,6 +55,7 @@ gethostbyaddr_t true_gethostbyaddr;
5555send_t true_send ;
5656sendto_t true_sendto ;
5757sendmsg_t true_sendmsg ;
58+ bind_t true_bind ;
5859
5960int tcp_read_time_out ;
6061int tcp_connect_time_out ;
@@ -479,45 +480,9 @@ int connect(int sock, const struct sockaddr *addr, socklen_t len) {
479480 return ret ;
480481}
481482
482- ssize_t send (int sockfd , const void * buf , size_t len , int flags ) {
483- //The send() call may be used only when the socket is in a connected state (so that the intended recipient is known)
484- //To avoid any hack this is watched for leak too
485-
486- /* If the real connect doesn't exist, we're stuffed */
487- if (true_send == NULL ) {
488- PDEBUG ("unresolved symbol: send\n\n" );
489- return -1 ;
490- }
491-
492- //return true_send(sockfd, buf, len, flags);
493- if (proxybound_allow_leak ) {
494- PDEBUG ("send: got send request\n" );
495- PDEBUG ("allowing direct send()\n\n" );
496- return true_send (sockfd , buf , len , flags );
497- //Already handled in connect ?
498- //TODO deeper handling (socktype)
499- } else {
500- int sock_type = -1 ;
501- unsigned int sock_type_len = sizeof (sock_type );
502-
503- /* Get the type of the socket */
504- getsockopt (sockfd , SOL_SOCKET , SO_TYPE , (void * ) & sock_type , & sock_type_len );
505-
506- if (sock_type != SOCK_STREAM ) {
507- //SOCK_STREAM
508- //SOCK_DGRAM
509- //SOCK_SEQPACKET
510- //SOCK_RAW
511- //SOCK_RDM
512- //SOCK_PACKET
513- PDEBUG ("send: blocking send request type SOCK_DGRAM/SOCK_SEQPACKET/SOCK_RAW/SOCK_RDM/SOCK_PACKET\n\n" );
514- return -1 ;
515- //TODO may block dns here
516- } else {
517- return true_send (sockfd , buf , len , flags );
518- }
519- return -1 ;
520- }
483+ int bind (int sockfd , const struct sockaddr * addr , socklen_t addrlen ) {
484+ PDEBUG ("bind: got a bind request\n\n" );
485+ return true_bind (sockfd , * addr , addrlen );
521486}
522487
523488ssize_t sendto (int sockfd , const void * buf , size_t len , int flags , const struct sockaddr * dest_addr , socklen_t addrlen ) {
@@ -581,6 +546,47 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, const struct
581546 return -1 ;
582547}
583548
549+ ssize_t send (int sockfd , const void * buf , size_t len , int flags ) {
550+ //The send() call may be used only when the socket is in a connected state (so that the intended recipient is known)
551+ //To avoid any hack this is watched for leak too
552+
553+ /* If the real connect doesn't exist, we're stuffed */
554+ if (true_send == NULL ) {
555+ PDEBUG ("unresolved symbol: send\n\n" );
556+ return -1 ;
557+ }
558+
559+ //return true_send(sockfd, buf, len, flags);
560+ if (proxybound_allow_leak ) {
561+ PDEBUG ("send: got send request\n" );
562+ PDEBUG ("allowing direct send()\n\n" );
563+ return true_send (sockfd , buf , len , flags );
564+ //Already handled in connect ?
565+ //TODO deeper handling (socktype)
566+ } else {
567+ int sock_type = -1 ;
568+ unsigned int sock_type_len = sizeof (sock_type );
569+
570+ /* Get the type of the socket */
571+ getsockopt (sockfd , SOL_SOCKET , SO_TYPE , (void * ) & sock_type , & sock_type_len );
572+
573+ if (sock_type != SOCK_STREAM ) {
574+ //SOCK_STREAM
575+ //SOCK_DGRAM
576+ //SOCK_SEQPACKET
577+ //SOCK_RAW
578+ //SOCK_RDM
579+ //SOCK_PACKET
580+ PDEBUG ("send: blocking send request type SOCK_DGRAM/SOCK_SEQPACKET/SOCK_RAW/SOCK_RDM/SOCK_PACKET\n\n" );
581+ return -1 ;
582+ //TODO may block dns here
583+ } else {
584+ return true_send (sockfd , buf , len , flags );
585+ }
586+ return -1 ;
587+ }
588+ }
589+
584590ssize_t sendmsg (int sockfd , const struct msghdr * msg , int flags ) {
585591
586592 struct sockaddr_in * connaddr ;
0 commit comments