- Optimise select loop.
- Remove unused function setup_outgoing_socket().
- Clear EVP_CIPHER_CTX structures before using them.
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: graph.c,v 1.1.2.21 2002/09/10 22:12:33 guus Exp $
+ $Id: graph.c,v 1.1.2.22 2003/01/17 00:37:17 guus Exp $
*/
/* We need to generate two trees from the graph:
/* Situation:
- /
+ /
/
------(n)-----(e->to)
\
- \
+ \
n->address is set to the e->address of the edge left of n to n.
We are currently examining the edge e right of n from n:
- If e->reverse->address != n->address, then e->to is probably
- not reachable for the nodes left of n. We do as if the indirectdata
- flag is set on edge e.
+ not reachable for the nodes left of n. We do as if the indirectdata
+ flag is set on edge e.
- If edge e provides for better reachability of e->to, update
- e->to and (re)add it to the todo_tree to (re)examine the reachability
- of nodes behind it.
+ e->to and (re)add it to the todo_tree to (re)examine the reachability
+ of nodes behind it.
*/
indirect = n->status.indirect || e->options & OPTION_INDIRECT
- || ((n != myself)
- && sockaddrcmp(&n->address, &e->reverse->address));
+ || ((n != myself) && sockaddrcmp(&n->address, &e->reverse->address));
if(e->to->status.visited
&& (!e->to->status.indirect || indirect))
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: net.c,v 1.35.4.182 2002/09/15 14:55:53 guus Exp $
+ $Id: net.c,v 1.35.4.183 2003/01/17 00:37:18 guus Exp $
*/
#include "config.h"
put all file descriptors in an fd_set array
While we're at it, purge stuff that needs to be removed.
*/
-void build_fdset(fd_set * fs)
+int build_fdset(fd_set * fs)
{
avl_node_t *node, *next;
connection_t *c;
- int i;
+ int i, max = 0;
cp();
connection_del(c);
if(!connection_tree->head)
purge();
- } else
+ } else {
FD_SET(c->socket, fs);
+ if(c->socket > max)
+ max = c->socket;
+ }
}
for(i = 0; i < listen_sockets; i++) {
FD_SET(listen_socket[i].tcp, fs);
+ if(listen_socket[i].tcp > max)
+ max = listen_socket[i].tcp;
FD_SET(listen_socket[i].udp, fs);
+ if(listen_socket[i].udp > max)
+ max = listen_socket[i].udp;
}
FD_SET(device_fd, fs);
+ if(device_fd > max)
+ max = device_fd;
+
+ return max;
}
/*
{
fd_set fset;
struct timeval tv;
- int r;
+ int r, maxfd;
time_t last_ping_check;
event_t *event;
tv.tv_sec = 1 + (rand() & 7); /* Approx. 5 seconds, randomized to prevent global synchronisation effects */
tv.tv_usec = 0;
- build_fdset(&fset);
+ maxfd = build_fdset(&fset);
- r = select(FD_SETSIZE, &fset, NULL, NULL, &tv);
+ r = select(maxfd + 1, &fset, NULL, NULL, &tv);
if(r < 0) {
if(errno != EINTR && errno != EAGAIN) {
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: net_socket.c,v 1.1.2.22 2002/09/15 14:55:53 guus Exp $
+ $Id: net_socket.c,v 1.1.2.23 2003/01/17 00:37:20 guus Exp $
*/
#include "config.h"
return -1;
}
#else
- syslog(LOG_WARNING, _("BindToDevice not supported on this platform"));
+ syslog(LOG_WARNING, _("BindToInterface not supported on this platform"));
#endif
}
outgoing->timeout);
}
-int setup_outgoing_socket(connection_t *c)
-{
- int option;
-
- cp();
-
- if(debug_lvl >= DEBUG_CONNECTIONS)
- syslog(LOG_INFO, _("Trying to connect to %s (%s)"), c->name,
- c->hostname);
-
- c->socket = socket(c->address.sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
-
- if(c->socket == -1) {
- syslog(LOG_ERR, _("Creating socket for %s failed: %s"), c->hostname,
- strerror(errno));
- return -1;
- }
-
- /* Optimize TCP settings */
-
-#if defined(SOL_TCP) && defined(TCP_NODELAY)
- option = 1;
- setsockopt(c->socket, SOL_TCP, TCP_NODELAY, &option, sizeof(option));
-#endif
-
-#if defined(SOL_IP) && defined(IP_TOS)
- option = IPTOS_LOWDELAY;
- setsockopt(c->socket, SOL_IP, IP_TOS, &option, sizeof(option));
-#endif
-
- /* Connect */
-
- if(connect(c->socket, &c->address.sa, SALEN(c->address.sa)) == -1) {
- close(c->socket);
- syslog(LOG_ERR, _("Error while connecting to %s (%s): %s"), c->name,
- c->hostname, strerror(errno));
- return -1;
- }
-
- if(debug_lvl >= DEBUG_CONNECTIONS)
- syslog(LOG_INFO, _("Connected to %s (%s)"), c->name, c->hostname);
-
- return 0;
-}
-
-
void finish_connecting(connection_t *c)
{
cp();
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: protocol_auth.c,v 1.1.4.18 2003/01/12 17:02:23 guus Exp $
+ $Id: protocol_auth.c,v 1.1.4.19 2003/01/17 00:37:20 guus Exp $
*/
#include "config.h"
c->outkey = xmalloc(len);
if(!c->outctx)
- c->outctx = xmalloc(sizeof(*c->outctx));
+ c->outctx = xmalloc_and_zero(sizeof(*c->outctx));
cp();
/* Copy random data to the buffer */
cp();
- if(sscanf
- (c->buffer, "%*d %d %d %d %d " MAX_STRING, &cipher, &digest, &maclength,
- &compression, buffer) != 5) {
+ if(sscanf(c->buffer, "%*d %d %d %d %d " MAX_STRING, &cipher, &digest, &maclength, &compression, buffer) != 5) {
syslog(LOG_ERR, _("Got bad %s from %s (%s)"), "METAKEY", c->name,
c->hostname);
return -1;
/* Check if the length of the meta key is all right */
if(strlen(buffer) != len * 2) {
- syslog(LOG_ERR, _("Possible intruder %s (%s): %s"), c->name,
- c->hostname, "wrong keylength");
+ syslog(LOG_ERR, _("Possible intruder %s (%s): %s"), c->name, c->hostname, "wrong keylength");
return -1;
}
c->inkey = xmalloc(len);
if(!c->inctx)
- c->inctx = xmalloc(sizeof(*c->inctx));
+ c->inctx = xmalloc_and_zero(sizeof(*c->inctx));
/* Convert the challenge from hexadecimal back to binary */
if(debug_lvl >= DEBUG_SCARY_THINGS) {
bin2hex(c->inkey, buffer, len);
buffer[len * 2] = '\0';
- syslog(LOG_DEBUG, _("Received random meta key (unencrypted): %s"),
- buffer);
+ syslog(LOG_DEBUG, _("Received random meta key (unencrypted): %s"), buffer);
}
/* All incoming requests will now be encrypted. */
if(cipher) {
c->incipher = EVP_get_cipherbynid(cipher);
-
+
if(!c->incipher) {
- syslog(LOG_ERR, _("%s (%s) uses unknown cipher!"), c->name,
- c->hostname);
+ syslog(LOG_ERR, _("%s (%s) uses unknown cipher!"), c->name, c->hostname);
return -1;
}
c->indigest = EVP_get_digestbynid(digest);
if(!c->indigest) {
- syslog(LOG_ERR, _("Node %s (%s) uses unknown digest!"), c->name,
- c->hostname);
+ syslog(LOG_ERR, _("Node %s (%s) uses unknown digest!"), c->name, c->hostname);
return -1;
}
if(c->inmaclength > c->indigest->md_size || c->inmaclength < 0) {
- syslog(LOG_ERR, _("%s (%s) uses bogus MAC length!"), c->name,
- c->hostname);
+ syslog(LOG_ERR, _("%s (%s) uses bogus MAC length!"), c->name, c->hostname);
return -1;
}
} else {