Changeset 1ffa73b in mainline for uspace/srv/net/il/ip/ip.c
- Timestamp:
- 2011-01-10T16:33:08Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b207803
- Parents:
- 863d45e (diff), 6610565b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/il/ip/ip.c
r863d45e r1ffa73b 275 275 if (rc != EOK) 276 276 goto out; 277 rc = add_module(NULL, &ip_globals.modules, ARP_NAME, ARP_FILENAME,278 SERVICE_ARP, 0, arp_connect_module);277 rc = add_module(NULL, &ip_globals.modules, (uint8_t *) ARP_NAME, 278 (uint8_t *) ARP_FILENAME, SERVICE_ARP, 0, arp_connect_module); 279 279 280 280 out: … … 312 312 measured_string_t names[] = { 313 313 { 314 ( char*) "IPV",314 (uint8_t *) "IPV", 315 315 3 316 316 }, 317 317 { 318 ( char*) "IP_CONFIG",318 (uint8_t *) "IP_CONFIG", 319 319 9 320 320 }, 321 321 { 322 ( char*) "IP_ADDR",322 (uint8_t *) "IP_ADDR", 323 323 7 324 324 }, 325 325 { 326 ( char*) "IP_NETMASK",326 (uint8_t *) "IP_NETMASK", 327 327 10 328 328 }, 329 329 { 330 ( char*) "IP_GATEWAY",330 (uint8_t *) "IP_GATEWAY", 331 331 10 332 332 }, 333 333 { 334 ( char*) "IP_BROADCAST",334 (uint8_t *) "IP_BROADCAST", 335 335 12 336 336 }, 337 337 { 338 ( char*) "ARP",338 (uint8_t *) "ARP", 339 339 3 340 340 }, 341 341 { 342 ( char*) "IP_ROUTING",342 (uint8_t *) "IP_ROUTING", 343 343 10 344 344 } … … 346 346 measured_string_t *configuration; 347 347 size_t count = sizeof(names) / sizeof(measured_string_t); 348 char*data;348 uint8_t *data; 349 349 measured_string_t address; 350 350 ip_route_t *route; … … 368 368 if (configuration) { 369 369 if (configuration[0].value) 370 ip_netif->ipv = strtol( configuration[0].value, NULL, 0);371 372 ip_netif->dhcp = !str_lcmp( configuration[1].value, "dhcp",370 ip_netif->ipv = strtol((char *) configuration[0].value, NULL, 0); 371 372 ip_netif->dhcp = !str_lcmp((char *) configuration[1].value, "dhcp", 373 373 configuration[1].length); 374 374 … … 394 394 } 395 395 396 if ((inet_pton(AF_INET, configuration[2].value,396 if ((inet_pton(AF_INET, (char *) configuration[2].value, 397 397 (uint8_t *) &route->address.s_addr) != EOK) || 398 (inet_pton(AF_INET, configuration[3].value,398 (inet_pton(AF_INET, (char *) configuration[3].value, 399 399 (uint8_t *) &route->netmask.s_addr) != EOK) || 400 (inet_pton(AF_INET, configuration[4].value,400 (inet_pton(AF_INET, (char *) configuration[4].value, 401 401 (uint8_t *) &gateway.s_addr) == EINVAL) || 402 (inet_pton(AF_INET, configuration[5].value,402 (inet_pton(AF_INET, (char *) configuration[5].value, 403 403 (uint8_t *) &ip_netif->broadcast.s_addr) == EINVAL)) 404 404 { … … 441 441 if (ip_netif->arp) { 442 442 if (route) { 443 address.value = ( char*) &route->address.s_addr;443 address.value = (uint8_t *) &route->address.s_addr; 444 444 address.length = sizeof(in_addr_t); 445 445 … … 477 477 ip_globals.gateway.gateway.s_addr = gateway.s_addr; 478 478 ip_globals.gateway.netif = ip_netif; 479 480 char defgateway[INET_ADDRSTRLEN]; 481 inet_ntop(AF_INET, (uint8_t *) &gateway.s_addr, 482 defgateway, INET_ADDRSTRLEN); 483 printf("%s: Default gateway (%s)\n", NAME, defgateway); 479 484 } 480 485 … … 997 1002 measured_string_t destination; 998 1003 measured_string_t *translation; 999 char*data;1004 uint8_t *data; 1000 1005 int phone; 1001 1006 int rc; … … 1004 1009 if (netif->arp && (route->address.s_addr != dest.s_addr)) { 1005 1010 destination.value = route->gateway.s_addr ? 1006 ( char *) &route->gateway.s_addr : (char*) &dest.s_addr;1011 (uint8_t *) &route->gateway.s_addr : (uint8_t *) &dest.s_addr; 1007 1012 destination.length = sizeof(dest.s_addr); 1008 1013 … … 1069 1074 int index; 1070 1075 ip_route_t *route; 1071 1076 1072 1077 if (!netif) 1073 1078 return NULL; 1074 1075 / / start with the first one - the direct route1079 1080 /* Start with the first one (the direct route) */ 1076 1081 for (index = 0; index < ip_routes_count(&netif->routes); index++) { 1077 1082 route = ip_routes_get_index(&netif->routes, index); 1078 if ( route&&1083 if ((route) && 1079 1084 ((route->address.s_addr & route->netmask.s_addr) == 1080 (destination.s_addr & route->netmask.s_addr))) {1085 (destination.s_addr & route->netmask.s_addr))) 1081 1086 return route; 1082 }1083 1087 } 1084 1088 … … 1288 1292 if (device_id > 0) { 1289 1293 netif = ip_netifs_find(&ip_globals.netifs, device_id); 1290 route = ip_netif_find_route(netif, * 1294 route = ip_netif_find_route(netif, *dest); 1291 1295 if (netif && !route && (ip_globals.gateway.netif == netif)) 1292 1296 route = &ip_globals.gateway; … … 1318 1322 } 1319 1323 } 1320 1324 1321 1325 // if the local host is the destination 1322 1326 if ((route->address.s_addr == dest->s_addr) && … … 1562 1566 socklen_t addrlen; 1563 1567 int rc; 1564 1568 1565 1569 header = (ip_header_t *) packet_get_data(packet); 1566 1570 if (!header) … … 1588 1592 return EINVAL; 1589 1593 } 1590 1594 1591 1595 // process ipopt and get destination 1592 1596 dest = ip_get_destination(header); … … 1609 1613 if (rc != EOK) 1610 1614 return rc; 1611 1615 1612 1616 route = ip_find_route(dest); 1613 1617 if (!route) { … … 1756 1760 (header->destination_address & route->netmask.s_addr))) { 1757 1761 // clear the ARP mapping if any 1758 address.value = ( char*) &header->destination_address;1762 address.value = (uint8_t *) &header->destination_address; 1759 1763 address.length = sizeof(header->destination_address); 1760 1764 arp_clear_address_req(netif->arp->phone, … … 1886 1890 int 1887 1891 ip_message_standalone(ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, 1888 int *answer_count)1892 size_t *answer_count) 1889 1893 { 1890 1894 packet_t *packet; … … 1905 1909 1906 1910 case IPC_M_CONNECT_TO_ME: 1907 return ip_register(IL_GET_PROTO( call), IL_GET_SERVICE(call),1908 IPC_GET_PHONE( call), NULL);1911 return ip_register(IL_GET_PROTO(*call), IL_GET_SERVICE(*call), 1912 IPC_GET_PHONE(*call), NULL); 1909 1913 1910 1914 case NET_IL_DEVICE: 1911 return ip_device_req_local(0, IPC_GET_DEVICE( call),1912 IPC_GET_SERVICE( call));1915 return ip_device_req_local(0, IPC_GET_DEVICE(*call), 1916 IPC_GET_SERVICE(*call)); 1913 1917 1914 1918 case NET_IL_SEND: 1915 1919 rc = packet_translate_remote(ip_globals.net_phone, &packet, 1916 IPC_GET_PACKET( call));1920 IPC_GET_PACKET(*call)); 1917 1921 if (rc != EOK) 1918 1922 return rc; 1919 return ip_send_msg_local(0, IPC_GET_DEVICE( call), packet, 0,1920 IPC_GET_ERROR( call));1923 return ip_send_msg_local(0, IPC_GET_DEVICE(*call), packet, 0, 1924 IPC_GET_ERROR(*call)); 1921 1925 1922 1926 case NET_IL_DEVICE_STATE: 1923 return ip_device_state_message(IPC_GET_DEVICE( call),1924 IPC_GET_STATE( call));1927 return ip_device_state_message(IPC_GET_DEVICE(*call), 1928 IPC_GET_STATE(*call)); 1925 1929 1926 1930 case NET_IL_RECEIVED: 1927 1931 rc = packet_translate_remote(ip_globals.net_phone, &packet, 1928 IPC_GET_PACKET( call));1932 IPC_GET_PACKET(*call)); 1929 1933 if (rc != EOK) 1930 1934 return rc; 1931 return ip_receive_message(IPC_GET_DEVICE( call), packet);1935 return ip_receive_message(IPC_GET_DEVICE(*call), packet); 1932 1936 1933 1937 case NET_IP_RECEIVED_ERROR: 1934 1938 rc = packet_translate_remote(ip_globals.net_phone, &packet, 1935 IPC_GET_PACKET( call));1939 IPC_GET_PACKET(*call)); 1936 1940 if (rc != EOK) 1937 1941 return rc; 1938 return ip_received_error_msg_local(0, IPC_GET_DEVICE( call),1939 packet, IPC_GET_TARGET( call), IPC_GET_ERROR(call));1942 return ip_received_error_msg_local(0, IPC_GET_DEVICE(*call), 1943 packet, IPC_GET_TARGET(*call), IPC_GET_ERROR(*call)); 1940 1944 1941 1945 case NET_IP_ADD_ROUTE: 1942 return ip_add_route_req_local(0, IPC_GET_DEVICE( call),1943 IP_GET_ADDRESS( call), IP_GET_NETMASK(call),1944 IP_GET_GATEWAY( call));1946 return ip_add_route_req_local(0, IPC_GET_DEVICE(*call), 1947 IP_GET_ADDRESS(*call), IP_GET_NETMASK(*call), 1948 IP_GET_GATEWAY(*call)); 1945 1949 1946 1950 case NET_IP_SET_GATEWAY: 1947 return ip_set_gateway_req_local(0, IPC_GET_DEVICE( call),1948 IP_GET_GATEWAY( call));1951 return ip_set_gateway_req_local(0, IPC_GET_DEVICE(*call), 1952 IP_GET_GATEWAY(*call)); 1949 1953 1950 1954 case NET_IP_GET_ROUTE: … … 1954 1958 return rc; 1955 1959 1956 rc = ip_get_route_req_local(0, IP_GET_PROTOCOL( call), addr,1960 rc = ip_get_route_req_local(0, IP_GET_PROTOCOL(*call), addr, 1957 1961 (socklen_t) addrlen, &device_id, &header, &headerlen); 1958 1962 if (rc != EOK) 1959 1963 return rc; 1960 1964 1961 IPC_SET_DEVICE( answer, device_id);1962 IP_SET_HEADERLEN( answer, headerlen);1965 IPC_SET_DEVICE(*answer, device_id); 1966 IP_SET_HEADERLEN(*answer, headerlen); 1963 1967 1964 1968 *answer_count = 2; … … 1972 1976 1973 1977 case NET_IL_PACKET_SPACE: 1974 rc = ip_packet_size_message(IPC_GET_DEVICE( call), &addrlen,1978 rc = ip_packet_size_message(IPC_GET_DEVICE(*call), &addrlen, 1975 1979 &prefix, &content, &suffix); 1976 1980 if (rc != EOK) 1977 1981 return rc; 1978 1982 1979 IPC_SET_ADDR( answer, addrlen);1980 IPC_SET_PREFIX( answer, prefix);1981 IPC_SET_CONTENT( answer, content);1982 IPC_SET_SUFFIX( answer, suffix);1983 IPC_SET_ADDR(*answer, addrlen); 1984 IPC_SET_PREFIX(*answer, prefix); 1985 IPC_SET_CONTENT(*answer, content); 1986 IPC_SET_SUFFIX(*answer, suffix); 1983 1987 *answer_count = 4; 1984 1988 return EOK; 1985 1989 1986 1990 case NET_IL_MTU_CHANGED: 1987 return ip_mtu_changed_message(IPC_GET_DEVICE( call),1988 IPC_GET_MTU( call));1991 return ip_mtu_changed_message(IPC_GET_DEVICE(*call), 1992 IPC_GET_MTU(*call)); 1989 1993 } 1990 1994 … … 2007 2011 while (true) { 2008 2012 ipc_call_t answer; 2009 int answer_count;2013 size_t count; 2010 2014 2011 2015 /* Clear the answer structure */ 2012 refresh_answer(&answer, & answer_count);2016 refresh_answer(&answer, &count); 2013 2017 2014 2018 /* Fetch the next message */ … … 2018 2022 /* Process the message */ 2019 2023 int res = il_module_message_standalone(callid, &call, &answer, 2020 & answer_count);2024 &count); 2021 2025 2022 2026 /* … … 2030 2034 2031 2035 /* Answer the message */ 2032 answer_call(callid, res, &answer, answer_count);2036 answer_call(callid, res, &answer, count); 2033 2037 } 2034 2038 }
Note:
See TracChangeset
for help on using the changeset viewer.