Mercurial > ecos
comparison packages/net/common/current/src/network_support.c @ 957:db3e0a2fda2f
2003-04-12 Andrew Lunn <andrew.lunn@ascom.ch>
* src/network_support.c (init_loopback_interface): Close the
socket when things go wrong otherwise we leak sockets.
* src/tftp_server.c (tftpd_server): Added support for IPv6 as well
as IPv4. Extended the multithreading support so that it works
correctly when there are multiple servers on multiple ports.
* doc/tcpip.sgml: Documentation for the changes made to the tftp
server.
2003-04-10 Andrew Lunn <andrew.lunn@ascom.ch>
* src/network_support.c (init_all_network_interfaces): Wait upto 4
seconds for a router solicit message to be received. Once we have
received the message we know we have a valid IPv6 address.
* src/tftp_client.c: Added support for IPv6. This requires two new
functions, tftp_client_{get|put} which are protocol version
independent.
* tests/tftp_client_test.c (tftp_test): Added tests which use IPv6
addresses.
2003-04-07 Andrew Lunn <andrew.lunn@ascom.ch>
* src/getaddrinfo.c (getaddrinfo): Correctly deal with node when
its not NULL. Its OK for the address to not parse for an address
family when AF_UNSPEC is passed in hints. Also get the socktype
correct when wildcarding for services that use UDP.
* tests/addr_test.c: Added more test cases which test IP addresses
in number format as node.
2003-04-05 Andrew Lunn <andrew.lunn@ascom.ch>
* cdl/net.cdl: Added addr_tests to the HW tests.
* tests/addr_test.c (net_test): void function not int.
* tests/ping_test.c (net_test): Added IPv6 ping test. This pings
the router which answers our router solicit message.
* src/ipv6_routing_thread.c (cyg_rs): Print out the router
advertisement message. Cleaned up the debug messages so they can
be disabled.
* src/ipv6_routing_thread.c (cyg_net_get_ipv6_advrouter): New
function to return the address of the router.
* include/network.h: Added prototype for above and
ipv6_start_routing_thread which did not have a prototype.
* src/ipv6_routing_thread.c (cyg_rs): Only wait 2 seconds before
sending the first solicit request rather than 10.
* src/dhcp_prot.c (do_dhcp_down_net): clear the if_laddrreq
before using it. If the request fails finish the IPv4 code rather
than returning,.
2003-04-02 Andrew Lunn <andrew.lunn@ascom.ch>
* tests/ping_lo_test.c: Added IPv6 ping test.
* src/getproto.c: Added the protocol ipv6-icmp.
| author | asl |
|---|---|
| date | Wed, 23 Apr 2003 08:52:08 +0000 |
| parents | 43dbc9753e8f |
| children | 16d247bb9c70 |
comparison
equal
deleted
inserted
replaced
| 956:d9b26cfc0657 | 957:db3e0a2fda2f |
|---|---|
| 126 perror("socket"); | 126 perror("socket"); |
| 127 return false; | 127 return false; |
| 128 } | 128 } |
| 129 if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one))) { | 129 if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one))) { |
| 130 perror("setsockopt"); | 130 perror("setsockopt"); |
| 131 close(s); | |
| 131 return false; | 132 return false; |
| 132 } | 133 } |
| 133 | 134 |
| 134 addrp = (struct sockaddr_in *) &ifr.ifr_addr; | 135 addrp = (struct sockaddr_in *) &ifr.ifr_addr; |
| 135 memset(addrp, 0, sizeof(*addrp)); | 136 memset(addrp, 0, sizeof(*addrp)); |
| 147 strcpy(ifr.ifr_name, "lo0"); | 148 strcpy(ifr.ifr_name, "lo0"); |
| 148 #endif | 149 #endif |
| 149 | 150 |
| 150 if (ioctl(s, SIOCSIFADDR, &ifr)) { | 151 if (ioctl(s, SIOCSIFADDR, &ifr)) { |
| 151 perror("SIOCIFADDR"); | 152 perror("SIOCIFADDR"); |
| 153 close(s); | |
| 152 return false; | 154 return false; |
| 153 } | 155 } |
| 154 | 156 |
| 155 #if 1 < CYGPKG_NET_NLOOP | 157 #if 1 < CYGPKG_NET_NLOOP |
| 156 // We cheat to make different nets for multiple loopback devs | 158 // We cheat to make different nets for multiple loopback devs |
| 164 return false; | 166 return false; |
| 165 } | 167 } |
| 166 ifr.ifr_flags = IFF_UP | IFF_BROADCAST | IFF_RUNNING; | 168 ifr.ifr_flags = IFF_UP | IFF_BROADCAST | IFF_RUNNING; |
| 167 if (ioctl(s, SIOCSIFFLAGS, &ifr)) { | 169 if (ioctl(s, SIOCSIFFLAGS, &ifr)) { |
| 168 perror("SIOCSIFFLAGS"); | 170 perror("SIOCSIFFLAGS"); |
| 171 close(s); | |
| 169 return false; | 172 return false; |
| 170 } | 173 } |
| 171 | 174 |
| 172 gateway.s_addr = htonl(INADDR_LOOPBACK); | 175 gateway.s_addr = htonl(INADDR_LOOPBACK); |
| 173 memset(&route, 0, sizeof(route)); | 176 memset(&route, 0, sizeof(route)); |
| 189 diag_printf("Route - dst: %s", inet_ntoa(((struct sockaddr_in *)&route.rt_dst)->sin_addr)); | 192 diag_printf("Route - dst: %s", inet_ntoa(((struct sockaddr_in *)&route.rt_dst)->sin_addr)); |
| 190 diag_printf(", mask: %s", inet_ntoa(((struct sockaddr_in *)&route.rt_genmask)->sin_addr)); | 193 diag_printf(", mask: %s", inet_ntoa(((struct sockaddr_in *)&route.rt_genmask)->sin_addr)); |
| 191 diag_printf(", gateway: %s\n", inet_ntoa(((struct sockaddr_in *)&route.rt_gateway)->sin_addr)); | 194 diag_printf(", gateway: %s\n", inet_ntoa(((struct sockaddr_in *)&route.rt_gateway)->sin_addr)); |
| 192 if (errno != EEXIST) { | 195 if (errno != EEXIST) { |
| 193 perror("SIOCADDRT 3"); | 196 perror("SIOCADDRT 3"); |
| 197 close(s); | |
| 194 return false; | 198 return false; |
| 195 } | 199 } |
| 196 } | 200 } |
| 197 close(s); | 201 close(s); |
| 198 return true; | 202 return true; |
| 281 { | 285 { |
| 282 static volatile int in_init_all_network_interfaces = 0; | 286 static volatile int in_init_all_network_interfaces = 0; |
| 283 #ifdef CYGPKG_IO_PCMCIA | 287 #ifdef CYGPKG_IO_PCMCIA |
| 284 cyg_netdevtab_entry_t *t; | 288 cyg_netdevtab_entry_t *t; |
| 285 #endif // CYGPKG_IO_PCMCIA | 289 #endif // CYGPKG_IO_PCMCIA |
| 290 #ifdef CYGOPT_NET_IPV6_ROUTING_THREAD | |
| 291 int rs_wait = 40; | |
| 292 #endif | |
| 286 | 293 |
| 287 cyg_scheduler_lock(); | 294 cyg_scheduler_lock(); |
| 288 while ( in_init_all_network_interfaces ) { | 295 while ( in_init_all_network_interfaces ) { |
| 289 // Another thread is doing this... | 296 // Another thread is doing this... |
| 290 cyg_scheduler_unlock(); | 297 cyg_scheduler_unlock(); |
| 453 dhcp_start_dhcp_mgt_thread(); | 460 dhcp_start_dhcp_mgt_thread(); |
| 454 #endif | 461 #endif |
| 455 | 462 |
| 456 #ifdef CYGOPT_NET_IPV6_ROUTING_THREAD | 463 #ifdef CYGOPT_NET_IPV6_ROUTING_THREAD |
| 457 ipv6_start_routing_thread(); | 464 ipv6_start_routing_thread(); |
| 465 | |
| 466 // Wait for router solicit process to happen. | |
| 467 while (rs_wait-- && !cyg_net_get_ipv6_advrouter(NULL)) { | |
| 468 cyg_thread_delay(10); | |
| 469 } | |
| 470 if (rs_wait == 0 ) { | |
| 471 diag_printf("No router solicit received\n"); | |
| 472 } | |
| 458 #endif | 473 #endif |
| 459 | 474 |
| 460 #ifdef CYGDAT_NS_DNS_DEFAULT_SERVER | 475 #ifdef CYGDAT_NS_DNS_DEFAULT_SERVER |
| 461 #define _SERVER string(CYGDAT_NS_DNS_DEFAULT_SERVER) | 476 #define _SERVER string(CYGDAT_NS_DNS_DEFAULT_SERVER) |
| 462 | 477 |
