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