From (spam-protected) Sat Oct 8 17:38:40 2005 From: (spam-protected) (Andreas Tønnesen) Date: Sat, 08 Oct 2005 15:38:40 +0000 Subject: [Olsr-cvs] olsrd-current/src/unix ifnet.c,1.29,1.30 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src/unix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15960 Modified Files: ifnet.c Log Message: Patch from Sven-Ola Index: ifnet.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/unix/ifnet.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** ifnet.c 28 Aug 2005 19:30:30 -0000 1.29 --- ifnet.c 8 Oct 2005 15:38:38 -0000 1.30 *************** *** 903,908 **** /* IP version 4 */ ifp->ip_addr.v4 = ((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr; - ((struct sockaddr_in *)&addrsock)->sin_addr.s_addr = - ((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr; /* *We create one socket for each interface and bind --- 903,906 ---- From (spam-protected) Sat Oct 8 17:43:58 2005 From: (spam-protected) (Andreas Tønnesen) Date: Sat, 08 Oct 2005 15:43:58 +0000 Subject: [Olsr-cvs] olsrd-current/src net_olsr.c, 1.3, 1.4 lq_packet.c, 1.16, 1.17 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16966 Modified Files: net_olsr.c lq_packet.c Log Message: Patch from Sven-Ola Index: lq_packet.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/lq_packet.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** lq_packet.c 25 May 2005 13:36:41 -0000 1.16 --- lq_packet.c 8 Oct 2005 15:43:56 -0000 1.17 *************** *** 774,777 **** --- 774,783 ---- struct hello_neighbor *new_neigh; + // SVEN_OLA: Check the message source addr + if(!olsr_validate_address(&lq_hello->comm.orig)) + { + return; + } + // XXX - translation is ugly; everybody should use lq_hello_message :-) *************** *** 794,797 **** --- 800,806 ---- for (neigh = lq_hello->neigh; neigh != NULL; neigh = neigh->next) { + // SVEN_OLA: Also check the neighbours + if(!olsr_validate_address(&neigh->addr)) continue; + // allocate HELLO neighbour *************** *** 825,828 **** --- 834,843 ---- struct tc_mpr_addr *new_neigh; + // SVEN_OLA: Check the message source addr + if(!olsr_validate_address(&lq_tc->from)||!olsr_validate_address(&lq_tc->comm.orig)) + { + return; + } + // XXX - translation is ugly; everybody should use lq_tc_message :-) *************** *** 845,848 **** --- 860,866 ---- for (neigh = lq_tc->neigh; neigh != NULL; neigh = neigh->next) { + // SVEN_OLA: Also check the neighbours + if(!olsr_validate_address(&neigh->main)) continue; + // allocate TC neighbour Index: net_olsr.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/net_olsr.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** net_olsr.c 30 May 2005 13:13:38 -0000 1.3 --- net_olsr.c 8 Oct 2005 15:43:56 -0000 1.4 *************** *** 73,76 **** --- 73,78 ---- { "0.0.0.0", + //SVEN_OLA: This address is not plausible too + "127.0.0.1", NULL }; From (spam-protected) Tue Oct 11 16:55:57 2005 From: (spam-protected) (Andreas Tønnesen) Date: Tue, 11 Oct 2005 14:55:57 +0000 Subject: [Olsr-cvs] olsrd-current/src olsr_protocol.h,1.18,1.19 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11836/src Modified Files: olsr_protocol.h Log Message: Added pack attribute to data structures based on feedback from XScale BE users Index: olsr_protocol.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/olsr_protocol.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** olsr_protocol.h 26 May 2005 11:11:10 -0000 1.18 --- olsr_protocol.h 11 Oct 2005 14:55:55 -0000 1.19 *************** *** 214,218 **** olsr_u16_t size; olsr_u32_t neigh_addr[1]; /* neighbor IP address(es) */ ! }; struct hellomsg --- 214,218 ---- olsr_u16_t size; olsr_u32_t neigh_addr[1]; /* neighbor IP address(es) */ ! } __attribute__ ((packed)); struct hellomsg *************** *** 222,226 **** olsr_u8_t willingness; struct hellinfo hell_info[1]; ! }; /* --- 222,226 ---- olsr_u8_t willingness; struct hellinfo hell_info[1]; ! } __attribute__ ((packed)); /* *************** *** 234,238 **** olsr_u16_t size; struct in6_addr neigh_addr[1]; /* neighbor IP address(es) */ ! }; struct hellomsg6 --- 234,238 ---- olsr_u16_t size; struct in6_addr neigh_addr[1]; /* neighbor IP address(es) */ ! } __attribute__ ((packed)); struct hellomsg6 *************** *** 242,246 **** olsr_u8_t willingness; struct hellinfo6 hell_info[1]; ! }; /* --- 242,246 ---- olsr_u8_t willingness; struct hellinfo6 hell_info[1]; ! } __attribute__ ((packed)); /* *************** *** 251,255 **** { olsr_u32_t addr; ! }; --- 251,255 ---- { olsr_u32_t addr; ! } __attribute__ ((packed)); *************** *** 259,263 **** olsr_u16_t reserved; struct neigh_info neigh[1]; ! }; --- 259,263 ---- olsr_u16_t reserved; struct neigh_info neigh[1]; ! } __attribute__ ((packed)); *************** *** 270,274 **** { struct in6_addr addr; ! }; --- 270,274 ---- { struct in6_addr addr; ! } __attribute__ ((packed)); *************** *** 278,282 **** olsr_u16_t reserved; struct neigh_info6 neigh[1]; ! }; --- 278,282 ---- olsr_u16_t reserved; struct neigh_info6 neigh[1]; ! } __attribute__ ((packed)); *************** *** 296,300 **** { olsr_u32_t addr; ! }; --- 296,300 ---- { olsr_u32_t addr; ! } __attribute__ ((packed)); *************** *** 302,306 **** { struct midaddr mid_addr[1]; ! }; --- 302,306 ---- { struct midaddr mid_addr[1]; ! } __attribute__ ((packed)); *************** *** 311,315 **** { struct in6_addr addr; ! }; --- 311,315 ---- { struct in6_addr addr; ! } __attribute__ ((packed)); *************** *** 317,321 **** { struct midaddr6 mid_addr[1]; ! }; --- 317,321 ---- { struct midaddr6 mid_addr[1]; ! } __attribute__ ((packed)); *************** *** 331,340 **** olsr_u32_t addr; olsr_u32_t netmask; ! }; struct hnamsg { struct hnapair hna_net[1]; ! }; /* --- 331,340 ---- olsr_u32_t addr; olsr_u32_t netmask; ! } __attribute__ ((packed)); struct hnamsg { struct hnapair hna_net[1]; ! } __attribute__ ((packed)); /* *************** *** 346,355 **** struct in6_addr addr; struct in6_addr netmask; ! }; struct hnamsg6 { struct hnapair6 hna_net[1]; ! }; --- 346,355 ---- struct in6_addr addr; struct in6_addr netmask; ! } __attribute__ ((packed)); struct hnamsg6 { struct hnapair6 hna_net[1]; ! } __attribute__ ((packed)); *************** *** 379,383 **** } message; ! }; /* --- 379,383 ---- } message; ! } __attribute__ ((packed)); /* *************** *** 403,407 **** } message; ! }; --- 403,407 ---- } message; ! } __attribute__ ((packed)); *************** *** 416,420 **** olsr_u16_t olsr_seqno; struct olsrmsg olsr_msg[1]; /* variable messages */ ! }; --- 416,420 ---- olsr_u16_t olsr_seqno; struct olsrmsg olsr_msg[1]; /* variable messages */ ! } __attribute__ ((packed)); *************** *** 424,428 **** olsr_u16_t olsr_seqno; struct olsrmsg6 olsr_msg[1]; /* variable messages */ ! }; --- 424,428 ---- olsr_u16_t olsr_seqno; struct olsrmsg6 olsr_msg[1]; /* variable messages */ ! } __attribute__ ((packed)); *************** *** 433,437 **** struct olsrmsg v4; struct olsrmsg6 v6; ! }; union olsr_packet --- 433,437 ---- struct olsrmsg v4; struct olsrmsg6 v6; ! } __attribute__ ((packed)); union olsr_packet *************** *** 439,443 **** struct olsr v4; struct olsr6 v6; ! }; --- 439,443 ---- struct olsr v4; struct olsr6 v6; ! } __attribute__ ((packed)); From (spam-protected) Sun Oct 23 21:01:07 2005 From: (spam-protected) (Thomas Lopatic) Date: Sun, 23 Oct 2005 19:01:07 +0000 Subject: [Olsr-cvs] olsrd-current/src/win32 ifnet.c,1.28,1.29 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23711/src/win32 Modified Files: ifnet.c Log Message: olsr_switch looks okay on Windows. Windows port uses correct MTU. With LQ enabled minimal HELLO-validity-time is HELLO-interval x LQ-Window-Size. Index: ifnet.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/win32/ifnet.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** ifnet.c 4 Aug 2005 20:45:29 -0000 1.28 --- ifnet.c 23 Oct 2005 19:01:04 -0000 1.29 *************** *** 184,187 **** --- 184,190 ---- Info->Mtu = (int)IfTable->table[TabIdx].dwMtu; + Info->Mtu -= (olsr_cnf->ip_version == AF_INET6) ? + UDP_IPV6_HDRSIZE : UDP_IPV4_HDRSIZE; + BuffLen = sizeof (AdInfo); *************** *** 483,487 **** ifp->int_mtu = OLSR_DEFAULT_MTU; ! ifp->int_mtu -= (olsr_cnf->ip_version == AF_INET6) ? UDP_IPV6_HDRSIZE : UDP_IPV4_HDRSIZE; /* Set up buffer */ --- 486,491 ---- ifp->int_mtu = OLSR_DEFAULT_MTU; ! ifp->int_mtu -= (olsr_cnf->ip_version == AF_INET6) ? ! UDP_IPV6_HDRSIZE : UDP_IPV4_HDRSIZE; /* Set up buffer */ *************** *** 551,555 **** addr[3] = htonl(addr[3]); ! if(send(ifp->olsr_socket, addr , ipsize, 0) != (int)ipsize) { fprintf(stderr, "Error sending IP!"); --- 555,559 ---- addr[3] = htonl(addr[3]); ! if(send(ifp->olsr_socket, (char *)addr, ipsize, 0) != (int)ipsize) { fprintf(stderr, "Error sending IP!"); From (spam-protected) Sun Oct 23 21:01:06 2005 From: (spam-protected) (Thomas Lopatic) Date: Sun, 23 Oct 2005 19:01:06 +0000 Subject: [Olsr-cvs] olsrd-current/src/cfgparser olsrd_conf.c,1.42,1.43 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src/cfgparser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23711/src/cfgparser Modified Files: olsrd_conf.c Log Message: olsr_switch looks okay on Windows. Windows port uses correct MTU. With LQ enabled minimal HELLO-validity-time is HELLO-interval x LQ-Window-Size. Index: olsrd_conf.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/cfgparser/olsrd_conf.c,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** olsrd_conf.c 17 Sep 2005 20:48:50 -0000 1.42 --- olsrd_conf.c 23 Oct 2005 19:01:04 -0000 1.43 *************** *** 317,320 **** --- 317,334 ---- } + if (cnf->lq_level > 0) + { + float want = cnf->lq_wsize * io->hello_params.emission_interval; + + if (io->hello_params.validity_time < want) + { + io->hello_params.validity_time = want; + + fprintf(stderr, + "WARNING: %s HELLO validity time set to %.1f seconds!\n", + in->name, want); + } + } + /* TC interval */ if(io->tc_params.emission_interval < cnf->pollrate || From (spam-protected) Sun Oct 23 21:01:06 2005 From: (spam-protected) (Thomas Lopatic) Date: Sun, 23 Oct 2005 19:01:06 +0000 Subject: [Olsr-cvs] olsrd-current/src/olsr_switch main.c, 1.20, 1.21 ohs_cmd.c, 1.16, 1.17 ohs_cmd.h, 1.4, 1.5 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src/olsr_switch In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23711/src/olsr_switch Modified Files: main.c ohs_cmd.c ohs_cmd.h Log Message: olsr_switch looks okay on Windows. Windows port uses correct MTU. With LQ enabled minimal HELLO-validity-time is HELLO-interval x LQ-Window-Size. Index: ohs_cmd.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/olsr_switch/ohs_cmd.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ohs_cmd.c 4 Aug 2005 18:57:11 -0000 1.16 --- ohs_cmd.c 23 Oct 2005 19:01:04 -0000 1.17 *************** *** 56,62 **** - #define ARG_BUF_SIZE 500 - static char arg_buf[ARG_BUF_SIZE]; - #define TOK_BUF_SIZE 500 static char tok_buf[TOK_BUF_SIZE]; --- 56,59 ---- *************** *** 65,84 **** static char olsrd_path[FILENAME_MAX]; - static void - get_arg_buf(FILE *handle, char *buf, size_t size) - { - char c = 0; - int pos = 0; - - while(((c = fgetc(handle)) != '\n') && - pos < ((int)size - 2)) - { - buf[pos] = c; - pos++; - } - - buf[pos] = 0; - } - static int get_next_token(char *src, char *dst, size_t buflen) --- 62,65 ---- *************** *** 115,119 **** int ! ohs_cmd_olsrd(FILE *handle, char *args) { #ifdef WIN32 --- 96,100 ---- int ! ohs_cmd_olsrd(char *args) { #ifdef WIN32 *************** *** 251,255 **** int ! ohs_cmd_link(FILE *handle, char *args) { olsr_u8_t bi = 0, wildc_src = 0, wildc_dst = 0; --- 232,236 ---- int ! ohs_cmd_link(char *args) { olsr_u8_t bi = 0, wildc_src = 0, wildc_dst = 0; *************** *** 405,409 **** int ! ohs_cmd_list(FILE *handle, char *args) { struct ohs_connection *oc = ohs_conns; --- 386,390 ---- int ! ohs_cmd_list(char *args) { struct ohs_connection *oc = ohs_conns; *************** *** 454,458 **** int ! ohs_cmd_help(FILE *handle, char *args) { int i; --- 435,439 ---- int ! ohs_cmd_help(char *args) { int i; *************** *** 494,498 **** int ! ohs_cmd_log(FILE *handle, char *args) { olsr_u8_t set = 0; --- 475,479 ---- int ! ohs_cmd_log(char *args) { olsr_u8_t set = 0; *************** *** 555,559 **** int ! ohs_cmd_exit(FILE *handle, char *args) { --- 536,540 ---- int ! ohs_cmd_exit(char *args) { *************** *** 564,599 **** } ! int ! ohs_parse_command(FILE *handle) { ! char input_data[100]; int i; ! fscanf(handle, "%s", input_data); ! get_arg_buf(handle, arg_buf, ARG_BUF_SIZE); ! for(i = 0; ohs_commands[i].cmd; i++) { ! if(!strcmp(input_data, ohs_commands[i].cmd)) ! { ! if(ohs_commands[i].cmd_cb) ! { ! ohs_commands[i].cmd_cb(handle, arg_buf); ! } ! else ! { ! printf("No action registered on cmd %s!\n", input_data); ! } ! break; ! } } ! if(!ohs_commands[i].cmd) ! { ! printf("%s: no such cmd!\n", input_data); ! } ! ! return 0; } --- 545,632 ---- } ! void ! ohs_parse_command(void) { ! static char cmd_line[500]; ! static int cmd_len = 0; ! char c; ! char *args; ! char cmd_token[20]; int i; + #if defined WIN32 + unsigned long Read; + INPUT_RECORD InRec; + KEY_EVENT_RECORD *KeyEventRec; + #endif ! #if defined WIN32 ! if (!ReadConsoleInput(GetStdHandle(STD_INPUT_HANDLE), &InRec, sizeof (InRec), &Read)) ! { ! fprintf(stderr, "ReadConsoleInput failed: %s\n", strerror(GetLastError())); ! return; ! } ! if (InRec.EventType != KEY_EVENT) ! return; ! KeyEventRec = &InRec.Event.KeyEvent; ! ! if (!KeyEventRec->bKeyDown) ! return; ! ! c = KeyEventRec->uChar.AsciiChar; ! ! if (c == 8) ! { ! if (cmd_len == 0) ! return; ! ! cmd_len--; ! ! fputc(8, stdout); ! fputc(32, stdout); ! fputc(8, stdout); ! ! fflush(stdout); ! ! return; ! } ! ! fputc(c, stdout); ! fflush(stdout); ! ! #else ! c = fgetc(stdin); ! #endif ! ! if (c != '\n' && c != '\r' && cmd_len < (int)sizeof (cmd_line) - 1) ! cmd_line[cmd_len++] = (char)c; ! ! else ! { ! cmd_line[cmd_len] = 0; ! cmd_len = 0; ! ! args = cmd_line + get_next_token(cmd_line, cmd_token, sizeof (cmd_token)); ! ! for (i = 0; ohs_commands[i].cmd != NULL; i++) { ! if (strcmp(cmd_token, ohs_commands[i].cmd) == 0) ! { ! if(ohs_commands[i].cmd_cb != NULL) ! ohs_commands[i].cmd_cb(args); ! ! else ! printf("No action registered on cmd %s!\n", cmd_token); ! ! break; ! } } ! if(ohs_commands[i].cmd == NULL) ! printf("%s: no such cmd!\n", cmd_token); ! printf("\n> "); ! fflush(stdout); ! } } Index: ohs_cmd.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/olsr_switch/ohs_cmd.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ohs_cmd.h 4 Jun 2005 21:07:33 -0000 1.4 --- ohs_cmd.h 23 Oct 2005 19:01:04 -0000 1.5 *************** *** 53,57 **** char *helptext_brief; char *helptext_long; ! int (*cmd_cb)(FILE *, char *); }; --- 53,57 ---- char *helptext_brief; char *helptext_long; ! int (*cmd_cb)(char *); }; *************** *** 59,82 **** ohs_set_olsrd_path(char *); ! int ! ohs_parse_command(FILE *); int ! ohs_cmd_olsrd(FILE *, char *); int ! ohs_cmd_list(FILE *, char *); int ! ohs_cmd_help(FILE *, char *); int ! ohs_cmd_exit(FILE *, char *); int ! ohs_cmd_log(FILE *, char *); int ! ohs_cmd_link(FILE *, char *); #endif --- 59,82 ---- ohs_set_olsrd_path(char *); ! void ! ohs_parse_command(void); int ! ohs_cmd_olsrd(char *); int ! ohs_cmd_list(char *); int ! ohs_cmd_help(char *); int ! ohs_cmd_exit(char *); int ! ohs_cmd_log(char *); int ! ohs_cmd_link(char *); #endif Index: main.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/olsr_switch/main.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** main.c 5 Aug 2005 15:15:19 -0000 1.20 --- main.c 23 Oct 2005 19:01:04 -0000 1.21 *************** *** 59,68 **** #ifdef WIN32 - #undef EINTR - #define EINTR WSAEINTR #undef errno #define errno WSAGetLastError() #undef strerror #define strerror(x) StrError(x) #else #include --- 59,67 ---- #ifdef WIN32 #undef errno #define errno WSAGetLastError() #undef strerror #define strerror(x) StrError(x) + #define close(x) closesocket(x) #else #include *************** *** 162,165 **** --- 161,165 ---- struct ohs_connection *oc; olsr_u8_t new_addr[4]; + int i; if(logbits & LOG_CONNECT) *************** *** 180,189 **** oc->linkcnt = 0; /* Get "fake IP" */ ! if(recv(oc->socket, new_addr, 4, 0) != 4) ! { ! printf("Failed to fetch IP address!\n"); ! return -1; ! } memcpy(&oc->ip_addr, new_addr, 4); oc->ip_addr.v4 = ntohl(oc->ip_addr.v4); --- 180,204 ---- oc->linkcnt = 0; + // hack alert: WSAEventSelect makes sockets non-blocking, so the + // recv() may return without having read anything on Windows; hence + // re-try for 2 seconds on Windows; shouldn't harm Linux et al. + /* Get "fake IP" */ ! for (i = 0; i < 20; i++) ! { ! if (recv(oc->socket, new_addr, 4, 0) == 4) ! break; ! ! #if defined WIN32 ! Sleep(100); ! #endif ! } ! ! if (i == 20) ! { ! printf("Failed to fetch IP address! (%s)\n", strerror(errno)); ! return -1; ! } ! memcpy(&oc->ip_addr, new_addr, 4); oc->ip_addr.v4 = ntohl(oc->ip_addr.v4); *************** *** 348,367 **** } static void ohs_listen_loop() { int n; fd_set ibits; - #ifdef WIN32 - struct timeval select_timeout; - HANDLE stdIn = GetStdHandle(STD_INPUT_HANDLE); - #else int fn_stdin = fileno(stdin); - #endif - - printf("OHS command interpreter reading from STDIN\n"); - printf("\n> "); - fflush(stdout); while(1) --- 363,403 ---- } + static void accept_handler(void) + { + struct sockaddr_in pin; + socklen_t addrlen = sizeof(pin); + int s; + + memset(&pin, 0 , sizeof(pin)); + + if((s = accept(srv_socket, (struct sockaddr *)&pin, &addrlen)) < 0) + { + printf("accept failed socket: %s\n", strerror(errno)); + } + else + { + /* Create new node */ + ohs_init_new_connection(s); + } + } + + static void stdin_handler(void) + { + ohs_parse_command(); + } + + static void read_handler(struct ohs_connection *con) + { + if (ohs_route_data(con) < 0) + ohs_delete_connection(con); + } static void ohs_listen_loop() { + #if !defined WIN32 int n; fd_set ibits; int fn_stdin = fileno(stdin); while(1) *************** *** 378,390 **** FD_SET(srv_socket, &ibits); - #ifdef WIN32 - select_timeout.tv_sec = 0; - select_timeout.tv_usec = 5; - #else if(fn_stdin > high) high = fn_stdin; FD_SET(fn_stdin, &ibits); ! #endif /* Add clients */ for(ohs_cs = ohs_conns; ohs_cs; ohs_cs = ohs_cs->next) --- 414,422 ---- FD_SET(srv_socket, &ibits); if(fn_stdin > high) high = fn_stdin; FD_SET(fn_stdin, &ibits); ! /* Add clients */ for(ohs_cs = ohs_conns; ohs_cs; ohs_cs = ohs_cs->next) *************** *** 396,412 **** } - #ifdef WIN32 - n = select(high + 1, &ibits, 0, 0, &select_timeout); - #else /* block */ n = select(high + 1, &ibits, 0, 0, NULL); - #endif if(n == 0) - #ifdef WIN32 - goto read_stdin; - #else continue; - #endif /* Did somethig go wrong? */ --- 428,436 ---- *************** *** 417,446 **** printf("Error select: %s", strerror(errno)); - #ifdef WIN32 - goto read_stdin; - #else continue; - #endif } /* Check server socket */ if(FD_ISSET(srv_socket, &ibits)) ! { ! struct sockaddr_in pin; ! socklen_t addrlen = sizeof(pin); ! int s; ! ! memset(&pin, 0 , sizeof(pin)); - if((s = accept(srv_socket, (struct sockaddr *)&pin, &addrlen)) < 0) - { - printf("accept failed socket: %s\n", strerror(errno)); - } - else - { - /* Create new node */ - ohs_init_new_connection(s); - } - } /* Loop trough clients */ ohs_cs = ohs_conns; --- 441,451 ---- printf("Error select: %s", strerror(errno)); continue; } /* Check server socket */ if(FD_ISSET(srv_socket, &ibits)) ! accept_handler(); /* Loop trough clients */ ohs_cs = ohs_conns; *************** *** 451,472 **** if(FD_ISSET(ohs_tmp->socket, &ibits)) ! { ! if(ohs_route_data(ohs_tmp) < 0) ! ohs_delete_connection(ohs_tmp); ! } } ! #if WIN32 ! read_stdin: ! if(WaitForSingleObject(stdIn, 5L) == WAIT_OBJECT_0) ! #else if(FD_ISSET(fn_stdin, &ibits)) ! #endif ! { ! ohs_parse_command(stdin); ! printf("\n> "); ! fflush(stdout); ! } printf("*"); } } --- 456,535 ---- if(FD_ISSET(ohs_tmp->socket, &ibits)) ! read_handler(ohs_tmp); } ! if(FD_ISSET(fn_stdin, &ibits)) ! stdin_handler(); ! printf("*"); + fflush(stdout); } + #else + HANDLE Objects[2]; + WSANETWORKEVENTS NetEvents; + struct ohs_connection *Walker, *TmpWalker; + unsigned int Res; + + Objects[0] = GetStdHandle(STD_INPUT_HANDLE); + Objects[1] = WSACreateEvent(); + + if (WSAEventSelect(srv_socket, Objects[1], FD_ACCEPT) == SOCKET_ERROR) + { + fprintf(stderr, "WSAEventSelect failed (1): %s\n", strerror(errno)); + return; + } + + while (1) + { + for (Walker = ohs_conns; Walker != NULL; Walker = Walker->next) + { + if (WSAEventSelect(Walker->socket, Objects[1], FD_READ | FD_CLOSE) == SOCKET_ERROR) + { + fprintf(stderr, "WSAEventSelect failed (2): %s\n", strerror(errno)); + Sleep(1000); + continue; + } + } + + Res = WaitForMultipleObjects(2, Objects, FALSE, INFINITE); + + if (Res == WAIT_FAILED) + { + fprintf(stderr, "WaitForMultipleObjects failed: %s\n", strerror(GetLastError())); + Sleep(1000); + continue; + } + + if (Res == WAIT_OBJECT_0) + stdin_handler(); + + else if (Res == WAIT_OBJECT_0 + 1) + { + if (WSAEnumNetworkEvents(srv_socket, Objects[1], &NetEvents) == SOCKET_ERROR) + fprintf(stderr, "WSAEnumNetworkEvents failed (1): %s\n", strerror(errno)); + + else + { + if ((NetEvents.lNetworkEvents & FD_ACCEPT) != 0) + accept_handler(); + } + + for (Walker = ohs_conns; Walker != NULL; Walker = TmpWalker) + { + TmpWalker = Walker->next; + + if (WSAEnumNetworkEvents(Walker->socket, Objects[1], &NetEvents) == SOCKET_ERROR) + fprintf(stderr, "WSAEnumNetworkEvents failed (2): %s\n", strerror(errno)); + + else + { + if ((NetEvents.lNetworkEvents & (FD_READ | FD_CLOSE)) != 0) + read_handler(Walker); + } + } + } + } + + #endif } *************** *** 483,487 **** --- 546,552 ---- exit(EXIT_FAILURE); } + SetConsoleCtrlHandler(ohs_close, OLSR_TRUE); + #else signal(SIGINT, ohs_close); *************** *** 506,509 **** --- 571,578 ---- ohs_configure(); + printf("OHS command interpreter reading from STDIN\n"); + printf("\n> "); + fflush(stdout); + ohs_listen_loop(); From (spam-protected) Sun Oct 23 21:17:50 2005 From: (spam-protected) (Thomas Lopatic) Date: Sun, 23 Oct 2005 19:17:50 +0000 Subject: [Olsr-cvs] olsrd-current/src/olsr_switch ohs_cmd.c,1.17,1.18 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src/olsr_switch In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28555/src/olsr_switch Modified Files: ohs_cmd.c Log Message: olsr_switch now works again on Linux, too. Index: ohs_cmd.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/olsr_switch/ohs_cmd.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ohs_cmd.c 23 Oct 2005 19:01:04 -0000 1.17 --- ohs_cmd.c 23 Oct 2005 19:17:48 -0000 1.18 *************** *** 596,607 **** fflush(stdout); - #else - c = fgetc(stdin); - #endif - if (c != '\n' && c != '\r' && cmd_len < (int)sizeof (cmd_line) - 1) cmd_line[cmd_len++] = (char)c; else { cmd_line[cmd_len] = 0; --- 596,610 ---- fflush(stdout); if (c != '\n' && c != '\r' && cmd_len < (int)sizeof (cmd_line) - 1) cmd_line[cmd_len++] = (char)c; else + #else + fgets(cmd_line, sizeof (cmd_line), stdin); + + for (cmd_len = 0; cmd_line[cmd_len] != 0 && cmd_line[cmd_len] != '\n'; + cmd_len++); + #endif + { cmd_line[cmd_len] = 0; From (spam-protected) Sun Oct 23 22:11:52 2005 From: (spam-protected) (Thomas Lopatic) Date: Sun, 23 Oct 2005 20:11:52 +0000 Subject: [Olsr-cvs] olsrd-current/src lq_route.c,1.35,1.36 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8366/src Modified Files: lq_route.c Log Message: Use a sorted vertex list so that we are deterministic in case we have two or more equally good routes. Index: lq_route.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/lq_route.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** lq_route.c 25 May 2005 16:33:25 -0000 1.35 --- lq_route.c 23 Oct 2005 20:11:50 -0000 1.36 *************** *** 91,96 **** static int (*avl_comp)(void *, void *); ! static void add_vertex(struct avl_tree *vertex_tree, struct list *vertex_list, ! union olsr_ip_addr *addr, float path_etx) { struct avl_node *node; --- 91,96 ---- static int (*avl_comp)(void *, void *); ! static void add_vertex(struct avl_tree *vertex_tree, union olsr_ip_addr *addr, ! float path_etx) { struct avl_node *node; *************** *** 110,115 **** vert->tree_node.key = &vert->addr; - vert->node.data = vert; - COPY_IP(&vert->addr, addr); --- 110,113 ---- *************** *** 122,130 **** avl_insert(vertex_tree, &vert->tree_node); - list_add_tail(vertex_list, &vert->node); } } ! static void add_edge(struct avl_tree *vertex_tree, struct list *vertex_list, union olsr_ip_addr *src, union olsr_ip_addr *dst, float etx) --- 120,127 ---- avl_insert(vertex_tree, &vert->tree_node); } } ! static void add_edge(struct avl_tree *vertex_tree, union olsr_ip_addr *src, union olsr_ip_addr *dst, float etx) *************** *** 198,201 **** --- 195,238 ---- } + static void create_vertex_list_rec(struct list *vertex_list, + struct avl_node *node, + int (*comp)(void *, void *)) + { + struct dijk_vertex *vert = node->data; + + if (node->left != NULL) + create_vertex_list_rec(vertex_list, node->left, comp); + + // add the vertex to the list, if it's not us + + if ((*comp)(&main_addr, node->key) != 0) + { + vert->node.data = vert; + list_add_tail(vertex_list, &vert->node); + } + + if (node->right != NULL) + create_vertex_list_rec(vertex_list, node->right, comp); + } + + static void create_vertex_list(struct avl_tree *vertex_tree, + struct list *vertex_list) + { + struct avl_node *node; + struct dijk_vertex *vert; + + // make ourselves the first vertex in the list + + node = avl_find(vertex_tree, &main_addr); + vert = node->data; + + vert->node.data = vert; + list_add_tail(vertex_list, &vert->node); + + // add the remaining vertices ordered by their main address + + create_vertex_list_rec(vertex_list, vertex_tree->root, vertex_tree->comp); + } + static void free_everything(struct list *vertex_list) { *************** *** 343,349 **** list_init(&vertex_list); ! // add ourselves to the vertex list ! add_vertex(&vertex_tree, &vertex_list, &main_addr, 0.0); // add our neighbours --- 380,386 ---- list_init(&vertex_list); ! // add ourselves to the vertex tree ! add_vertex(&vertex_tree, &main_addr, 0.0); // add our neighbours *************** *** 353,358 **** neigh = neigh->next) if (neigh->status == SYM) ! add_vertex(&vertex_tree, &vertex_list, &neigh->neighbor_main_addr, ! INFINITE_ETX); // add our two-hop neighbours --- 390,394 ---- neigh = neigh->next) if (neigh->status == SYM) ! add_vertex(&vertex_tree, &neigh->neighbor_main_addr, INFINITE_ETX); // add our two-hop neighbours *************** *** 362,367 **** neigh2 != &two_hop_neighbortable[i]; neigh2 = neigh2->next) ! add_vertex(&vertex_tree, &vertex_list, &neigh2->neighbor_2_addr, ! INFINITE_ETX); // add remaining vertices --- 398,402 ---- neigh2 != &two_hop_neighbortable[i]; neigh2 = neigh2->next) ! add_vertex(&vertex_tree, &neigh2->neighbor_2_addr, INFINITE_ETX); // add remaining vertices *************** *** 372,377 **** // add source ! add_vertex(&vertex_tree, &vertex_list, &tcsrc->T_last_addr, ! INFINITE_ETX); // add destinations of this source --- 407,411 ---- // add source ! add_vertex(&vertex_tree, &tcsrc->T_last_addr, INFINITE_ETX); // add destinations of this source *************** *** 379,384 **** for (tcdst = tcsrc->destinations.next; tcdst != &tcsrc->destinations; tcdst = tcdst->next) ! add_vertex(&vertex_tree, &vertex_list, &tcdst->T_dest_addr, ! INFINITE_ETX); } --- 413,417 ---- for (tcdst = tcsrc->destinations.next; tcdst != &tcsrc->destinations; tcdst = tcdst->next) ! add_vertex(&vertex_tree, &tcdst->T_dest_addr, INFINITE_ETX); } *************** *** 397,402 **** etx = 1.0 / (link->loss_link_quality * link->neigh_link_quality); ! add_edge(&vertex_tree, &vertex_list, &neigh->neighbor_main_addr, ! &main_addr, etx); } } --- 430,434 ---- etx = 1.0 / (link->loss_link_quality * link->neigh_link_quality); ! add_edge(&vertex_tree, &neigh->neighbor_main_addr, &main_addr, etx); } } *************** *** 419,423 **** etx = 1.0 / neigh_walker->second_hop_link_quality; ! add_edge(&vertex_tree, &vertex_list, &neigh2->neighbor_2_addr, &neigh->neighbor_main_addr, etx); } --- 451,455 ---- etx = 1.0 / neigh_walker->second_hop_link_quality; ! add_edge(&vertex_tree, &neigh2->neighbor_2_addr, &neigh->neighbor_main_addr, etx); } *************** *** 436,444 **** etx = 1.0 / (tcdst->link_quality * tcdst->inverse_link_quality); ! add_edge(&vertex_tree, &vertex_list, &tcdst->T_dest_addr, ! &tcsrc->T_last_addr, etx); } } // run Dijkstra's algorithm --- 468,480 ---- etx = 1.0 / (tcdst->link_quality * tcdst->inverse_link_quality); ! add_edge(&vertex_tree, &tcdst->T_dest_addr, &tcsrc->T_last_addr, ! etx); } } + // create a sorted vertex list from the vertex tree + + create_vertex_list(&vertex_tree, &vertex_list); + // run Dijkstra's algorithm From (spam-protected) Sun Oct 23 22:58:16 2005 From: (spam-protected) (Thomas Lopatic) Date: Sun, 23 Oct 2005 20:58:16 +0000 Subject: [Olsr-cvs] olsrd-current/src link_set.c, 1.60, 1.61 link_set.h, 1.27, 1.28 lq_packet.c, 1.17, 1.18 lq_route.c, 1.36, 1.37 net_olsr.c, 1.4, 1.5 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17067/src Modified Files: link_set.c link_set.h lq_packet.c lq_route.c net_olsr.c Log Message: Only use updated link qualities for links between us and our neighbours after we have announced them to the world via an LQ TC message. The idea is that we use the updated link qualities only when everybody else does so, too. Index: lq_route.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/lq_route.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** lq_route.c 23 Oct 2005 20:11:50 -0000 1.36 --- lq_route.c 23 Oct 2005 20:58:14 -0000 1.37 *************** *** 366,370 **** --- 366,372 ---- struct rt_entry *gw_rt, *hna_rt, *head_rt; struct neighbor_2_entry *neigh2; + #if 0 struct neighbor_list_entry *neigh_walker; + #endif struct interface *inter; *************** *** 425,432 **** link = get_best_link_to_neighbor(&neigh->neighbor_main_addr); ! if (link->loss_link_quality >= MIN_LINK_QUALITY && ! link->neigh_link_quality >= MIN_LINK_QUALITY) { ! etx = 1.0 / (link->loss_link_quality * link->neigh_link_quality); add_edge(&vertex_tree, &neigh->neighbor_main_addr, &main_addr, etx); --- 427,434 ---- link = get_best_link_to_neighbor(&neigh->neighbor_main_addr); ! if (link->loss_link_quality2 >= MIN_LINK_QUALITY && ! link->neigh_link_quality2 >= MIN_LINK_QUALITY) { ! etx = 1.0 / (link->loss_link_quality2 * link->neigh_link_quality2); add_edge(&vertex_tree, &neigh->neighbor_main_addr, &main_addr, etx); *************** *** 434,437 **** --- 436,443 ---- } + // we now rely solely on TC messages for routes to our two-hop neighbours + + #if 0 + // add edges between our neighbours and our two-hop neighbours *************** *** 456,459 **** --- 462,467 ---- } + #endif + // add remaining edges Index: lq_packet.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/lq_packet.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** lq_packet.c 8 Oct 2005 15:43:56 -0000 1.17 --- lq_packet.c 23 Oct 2005 20:58:14 -0000 1.18 *************** *** 55,58 **** --- 55,60 ---- #include "olsr.h" + olsr_bool lq_tc_pending = OLSR_FALSE; + static unsigned char msg_buffer[MAXMESSAGESIZE - OLSR_HEADERSIZE]; *************** *** 149,152 **** --- 151,159 ---- struct link_entry *link; + // remember that we have generated an LQ TC message; this is + // checked in net_output() + + lq_tc_pending = OLSR_TRUE; + // initialize the static fields Index: net_olsr.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/net_olsr.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** net_olsr.c 8 Oct 2005 15:43:56 -0000 1.4 --- net_olsr.c 23 Oct 2005 20:58:14 -0000 1.5 *************** *** 45,50 **** --- 45,53 ---- #include "net_os.h" #include "print_packet.h" + #include "link_set.h" #include + extern olsr_bool lq_tc_pending; + #ifdef WIN32 #define perror(x) WinSockPError(x) *************** *** 489,492 **** --- 492,501 ---- netbufs[ifp->if_nr]->pending = 0; + // if we've just transmitted a TC message, let Dijkstra use the current + // link qualities for the links to our neighbours + + olsr_update_dijkstra_link_qualities(); + lq_tc_pending = OLSR_FALSE; + return 1; } Index: link_set.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.c,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** link_set.c 30 May 2005 13:13:38 -0000 1.60 --- link_set.c 23 Oct 2005 20:58:14 -0000 1.61 *************** *** 476,479 **** --- 476,482 ---- new_link->neigh_link_quality = 0.0; + new_link->loss_link_quality2 = 0.0; + new_link->neigh_link_quality2 = 0.0; + new_link->saved_loss_link_quality = 0.0; new_link->saved_neigh_link_quality = 0.0; *************** *** 1073,1074 **** --- 1076,1089 ---- } } + + void olsr_update_dijkstra_link_qualities() + { + struct link_entry *walker; + + for (walker = link_set; walker != NULL; walker = walker->next) + { + walker->loss_link_quality2 = walker->loss_link_quality; + walker->neigh_link_quality2 = walker->neigh_link_quality; + } + } + Index: link_set.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** link_set.h 29 May 2005 12:47:45 -0000 1.27 --- link_set.h 23 Oct 2005 20:58:14 -0000 1.28 *************** *** 86,90 **** int total_packets; ! double loss_link_quality; double loss_link_multiplier; --- 86,90 ---- int total_packets; ! double loss_link_quality, loss_link_quality2; double loss_link_multiplier; *************** *** 94,98 **** unsigned char loss_bitmap[16]; ! double neigh_link_quality; double saved_loss_link_quality; --- 94,98 ---- unsigned char loss_bitmap[16]; ! double neigh_link_quality, neigh_link_quality2; double saved_loss_link_quality; *************** *** 145,147 **** --- 145,150 ---- olsr_print_link_set(void); + void + olsr_update_dijkstra_link_qualities(void); + #endif From (spam-protected) Fri Oct 28 20:39:35 2005 From: (spam-protected) (Andreas Tønnesen) Date: Fri, 28 Oct 2005 18:39:35 +0000 Subject: [Olsr-cvs] olsrd-current/src scheduler.c,1.30,1.31 Message-ID: Update of /cvsroot/olsrd/olsrd-current/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2613/src Modified Files: scheduler.c Log Message: Checking for -1 and not negative on call to times Index: scheduler.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/scheduler.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** scheduler.c 29 Mar 2005 19:07:19 -0000 1.30 --- scheduler.c 28 Oct 2005 18:39:33 -0000 1.31 *************** *** 114,120 **** /* Update now_times */ ! if((now_times = times(&tms_buf)) < 0) { ! if((now_times = times(&tms_buf)) < 0) { fprintf(stderr, "Fatal!scheduler could not get new_times.\n%s\n", strerror(errno)); --- 114,120 ---- /* Update now_times */ ! if((now_times = times(&tms_buf)) == -1) { ! if((now_times = times(&tms_buf)) == -1) { fprintf(stderr, "Fatal!scheduler could not get new_times.\n%s\n", strerror(errno)); From (spam-protected) Fri Oct 28 21:16:11 2005 From: (spam-protected) (Andreas Tønnesen) Date: Fri, 28 Oct 2005 19:16:11 +0000 Subject: [Olsr-cvs] olsrd-current CHANGELOG,1.49,1.50 Message-ID: Update of /cvsroot/olsrd/olsrd-current In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10303 Modified Files: CHANGELOG Log Message: Checking for -1 and not negative on call to times Index: CHANGELOG =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/CHANGELOG,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** CHANGELOG 17 Sep 2005 20:48:49 -0000 1.49 --- CHANGELOG 28 Oct 2005 19:16:09 -0000 1.50 *************** *** 43,46 **** --- 43,47 ---- has changed IP and sends HELLO before its olsrd precess has detected the change. + - Fixed return value check on times(2) calls in the scheduler 0.4.9 --------------------------------------------------------------------- From (spam-protected) Fri Oct 28 21:21:34 2005 From: (spam-protected) (Andreas Tønnesen) Date: Fri, 28 Oct 2005 19:21:34 +0000 Subject: [Olsr-cvs] olsrd-current CHANGELOG,1.50,1.51 Message-ID: Update of /cvsroot/olsrd/olsrd-current In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11591 Modified Files: CHANGELOG Log Message: Added comment about olsr_switch Index: CHANGELOG =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/CHANGELOG,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** CHANGELOG 28 Oct 2005 19:16:09 -0000 1.50 --- CHANGELOG 28 Oct 2005 19:21:32 -0000 1.51 *************** *** 4,7 **** --- 4,17 ---- 0.4.10 -------------------------------------------------------------------- + OLSR NETWORK SIMULATOR + + An application called olsr_switch(sorry for the nameclash with the win32 + GUI) has been added. If olsrd is ran using the -hint option it can now + connect to olsr_switch and be part of a virtual network. This means + that multiple instances can be ran at the same host! The olsr_switch + application allows the user to define link variables on all viritual + links in the network, creating all possible topologies. Read more in + the readme file. + OPENBSD SUPPORT *************** *** 23,27 **** MATH LIB DEPENDENCY ! The dependency on the math lib came from the use of pow(3) in hte mantissa/exponent calculation. The calls to pow in this long forgotten code, was very unnessecarry. The pow calls are replaced with bitwise --- 33,37 ---- MATH LIB DEPENDENCY ! The dependency on the math lib came from the use of pow(3) in the mantissa/exponent calculation. The calls to pow in this long forgotten code, was very unnessecarry. The pow calls are replaced with bitwise