comparison tcp-accept.c @ 577:69e98c45db7c

- Progress for allowing specifying a listenaddr for tcp forwards
author Matt Johnston <matt@ucc.asn.au>
date Wed, 24 Feb 2010 16:13:15 +0000
parents c216212001fc
children d2daeb015138
comparison
equal deleted inserted replaced
518:ce104c8b0be1 577:69e98c45db7c
102 char portstring[NI_MAXSERV]; 102 char portstring[NI_MAXSERV];
103 int socks[DROPBEAR_MAX_SOCKS]; 103 int socks[DROPBEAR_MAX_SOCKS];
104 struct Listener *listener = NULL; 104 struct Listener *listener = NULL;
105 int nsocks; 105 int nsocks;
106 char* errstring = NULL; 106 char* errstring = NULL;
107 /* listen_spec = NULL indicates localhost */
108 const char* listen_spec = NULL;
109 107
110 TRACE(("enter listen_tcpfwd")) 108 TRACE(("enter listen_tcpfwd"))
111 109
112 /* first we try to bind, so don't need to do so much cleanup on failure */ 110 /* first we try to bind, so don't need to do so much cleanup on failure */
113 snprintf(portstring, sizeof(portstring), "%d", tcpinfo->listenport); 111 snprintf(portstring, sizeof(portstring), "%d", tcpinfo->listenport);
114 112
115 /* a listenaddr of "" will indicate all interfaces */ 113 nsocks = dropbear_listen(tcpinfo->listenaddr, portstring, socks,
116 if (opts.listen_fwd_all
117 && (strcmp(tcpinfo->listenaddr, "localhost") != 0) ) {
118 listen_spec = tcpinfo->listenaddr;
119 }
120
121 nsocks = dropbear_listen(listen_spec, portstring, socks,
122 DROPBEAR_MAX_SOCKS, &errstring, &ses.maxfd); 114 DROPBEAR_MAX_SOCKS, &errstring, &ses.maxfd);
123 if (nsocks < 0) { 115 if (nsocks < 0) {
124 dropbear_log(LOG_INFO, "TCP forward failed: %s", errstring); 116 dropbear_log(LOG_INFO, "TCP forward failed: %s", errstring);
125 m_free(errstring); 117 m_free(errstring);
126 TRACE(("leave listen_tcpfwd: dropbear_listen failed")) 118 TRACE(("leave listen_tcpfwd: dropbear_listen failed"))