Changeset 0773396 in mainline for uspace/srv/net/inetsrv/inetsrv.c


Ignore:
Timestamp:
2013-12-25T13:05:25Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bc54126c
Parents:
f4a47e52 (diff), 6946f23 (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.
Message:

merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/inetsrv/inetsrv.c

    rf4a47e52 r0773396  
    4646#include <stdlib.h>
    4747#include <sys/types.h>
    48 #include <net/socket_codes.h>
    4948#include "addrobj.h"
    5049#include "icmp.h"
     
    5554#include "inetcfg.h"
    5655#include "inetping.h"
    57 #include "inetping6.h"
    5856#include "inet_link.h"
    5957#include "reass.h"
     
    6361
    6462static inet_naddr_t solicited_node_mask = {
    65         .family = AF_INET6,
     63        .version = ip_v6,
    6664        .addr6 = {0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01, 0xff, 0, 0, 0},
    6765        .prefix = 104
    6866};
    6967
     68static inet_addr_t broadcast4_all_hosts = {
     69        .version = ip_v4,
     70        .addr = 0xffffffff
     71};
     72
    7073static inet_addr_t multicast_all_nodes = {
    71         .family = AF_INET6,
     74        .version = ip_v6,
    7275        .addr6 = {0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01}
    7376};
     
    111114                return EEXIST;
    112115        }
    113        
    114         rc = loc_service_register_with_iface(SERVICE_NAME_INETPING6, &sid,
    115             INET_PORT_PING6);
    116         if (rc != EOK) {
    117                 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed registering service (%d).", rc);
    118                 return EEXIST;
    119         }
    120        
    121         inet_sroute_t *sroute = inet_sroute_new();
    122         if (sroute == NULL) {
    123                 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed creating default route (%d).", rc);
    124                 return ENOMEM;
    125         }
    126 
    127         inet_naddr(&sroute->dest, 0, 0, 0, 0, 0);
    128         inet_addr(&sroute->router, 10, 0, 2, 2);
    129         sroute->name = str_dup("default");
    130         inet_sroute_add(sroute);
    131 
    132         rc = inet_link_discovery_start();
    133         if (rc != EOK)
    134                 return EEXIST;
    135116       
    136117        return EOK;
     
    186167{
    187168        inet_dir_t dir;
     169        inet_link_t *ilink;
    188170        int rc;
     171
     172        if (dgram->iplink != 0) {
     173                /* XXX TODO - IPv6 */
     174                log_msg(LOG_DEFAULT, LVL_DEBUG, "dgram directly to iplink %zu",
     175                    dgram->iplink);
     176                /* Send packet directly to the specified IP link */
     177                ilink = inet_link_get_by_id(dgram->iplink);
     178                if (ilink == 0)
     179                        return ENOENT;
     180
     181                if (dgram->src.version != ip_v4 ||
     182                        dgram->dest.version != ip_v4)
     183                        return EINVAL;
     184
     185                return inet_link_send_dgram(ilink, dgram->src.addr,
     186                    dgram->dest.addr, dgram, proto, ttl, df);
     187        }
     188
     189        log_msg(LOG_DEFAULT, LVL_DEBUG, "dgram to be routed");
     190
     191        /* Route packet using source/destination addresses */
    189192
    190193        rc = inet_find_dir(&dgram->src, &dgram->dest, dgram->tos, &dir);
     
    214217
    215218        /* Take source address from the address object */
     219        if (remote->version == ip_v4 && remote->addr == 0xffffffff) {
     220                /* XXX TODO - IPv6 */
     221                local->version = ip_v4;
     222                local->addr = 0;
     223                return EOK;
     224        }
     225
    216226        inet_naddr_addr(&dir.aobj->naddr, local);
    217227        return EOK;
     
    282292        inet_dgram_t dgram;
    283293       
    284         dgram.tos = IPC_GET_ARG1(*icall);
    285        
    286         uint8_t ttl = IPC_GET_ARG2(*icall);
     294        dgram.iplink = IPC_GET_ARG1(*icall);
     295        dgram.tos = IPC_GET_ARG2(*icall);
     296       
     297        uint8_t ttl = IPC_GET_ARG3(*icall);
    287298        int df = IPC_GET_ARG3(*icall);
    288299       
     
    433444                inetping_conn(iid, icall, arg);
    434445                break;
    435         case INET_PORT_PING6:
    436                 inetping6_conn(iid, icall, arg);
    437                 break;
    438446        default:
    439447                async_answer_0(iid, ENOTSUP);
     
    446454        fibril_mutex_lock(&client_list_lock);
    447455
    448         list_foreach(client_list, link) {
    449                 inet_client_t *client = list_get_instance(link, inet_client_t,
    450                     client_list);
    451 
     456        list_foreach(client_list, client_list, inet_client_t, client) {
    452457                if (client->protocol == proto) {
    453458                        fibril_mutex_unlock(&client_list_lock);
     
    527532        if ((addr != NULL) ||
    528533            (inet_naddr_compare_mask(&solicited_node_mask, &packet->dest)) ||
    529             (inet_addr_compare(&multicast_all_nodes, &packet->dest))) {
     534            (inet_addr_compare(&multicast_all_nodes, &packet->dest)) ||
     535            (inet_addr_compare(&broadcast4_all_hosts, &packet->dest))) {
    530536                /* Destined for one of the local addresses */
    531537
Note: See TracChangeset for help on using the changeset viewer.