Changeset b5ba8f6 in mainline for uspace/srv


Ignore:
Timestamp:
2013-09-13T13:11:53Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1eaa3cf
Parents:
95027b5 (diff), 1c5f6f8 (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

Location:
uspace/srv
Files:
7 added
19 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/audio/hound/audio_device.c

    r95027b5 rb5ba8f6  
    162162                }
    163163                audio_pcm_register_event_callback(dev->sess,
    164                     device_event_callback, dev);\
     164                    device_event_callback, dev);
    165165
    166166                /* Fill the buffer first. Fill the first two fragments,
  • uspace/srv/hid/compositor/compositor.c

    r95027b5 rb5ba8f6  
    143143static LIST_INITIALIZE(viewport_list);
    144144
     145static FIBRIL_MUTEX_INITIALIZE(discovery_mtx);
     146
    145147/** Input server proxy */
    146148static input_t *input;
     
    21142116}
    21152117
     2118static int discover_viewports(void)
     2119{
     2120        /* Create viewports and connect them to visualizers. */
     2121        category_id_t cat_id;
     2122        int rc = loc_category_get_id("visualizer", &cat_id, IPC_FLAG_BLOCKING);
     2123        if (rc != EOK) {
     2124                printf("%s: Failed to get visualizer category.\n", NAME);
     2125                return -1;
     2126        }
     2127       
     2128        service_id_t *svcs;
     2129        size_t svcs_cnt = 0;
     2130        rc = loc_category_get_svcs(cat_id, &svcs, &svcs_cnt);
     2131        if (rc != EOK || svcs_cnt == 0) {
     2132                printf("%s: Failed to get visualizer category services.\n", NAME);
     2133                return -1;
     2134        }
     2135
     2136        fibril_mutex_lock(&viewport_list_mtx); 
     2137        for (size_t i = 0; i < svcs_cnt; ++i) {
     2138                bool exists = false;
     2139                list_foreach(viewport_list, link, viewport_t, vp) {
     2140                        if (vp->dsid == svcs[i]) {
     2141                                exists = true;
     2142                                break;
     2143                        }
     2144                }
     2145               
     2146                if (exists)
     2147                        continue;
     2148               
     2149                char *svc_name;
     2150                rc = loc_service_get_name(svcs[i], &svc_name);
     2151                if (rc == EOK) {
     2152                        viewport_t *vp = viewport_create(svc_name);
     2153                        if (vp != NULL) {
     2154                                list_append(&vp->link, &viewport_list);
     2155                        }
     2156                }
     2157        }
     2158        fibril_mutex_unlock(&viewport_list_mtx);
     2159       
     2160        /* TODO damage only newly added viewports */
     2161        comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
     2162        return EOK;
     2163}
     2164
     2165static void category_change_cb(void)
     2166{
     2167        fibril_mutex_lock(&discovery_mtx);
     2168        discover_viewports();
     2169        fibril_mutex_unlock(&discovery_mtx);
     2170}
     2171
    21162172static int compositor_srv_init(char *input_svc, char *name)
    21172173{
     
    21652221        }
    21662222
    2167         /* Create viewports and connect them to visualizers. */
    2168         category_id_t cat_id;
    2169         rc = loc_category_get_id("visualizer", &cat_id, IPC_FLAG_BLOCKING);
     2223        rc = loc_register_cat_change_cb(category_change_cb);
    21702224        if (rc != EOK) {
    2171                 printf("%s: Failed to get visualizer category.\n", NAME);
     2225                printf("%s: Failed to register category change callback\n", NAME);
    21722226                input_disconnect();
    2173                 return -1;
    2174         }
    2175        
    2176         service_id_t *svcs;
    2177         size_t svcs_cnt = 0;
    2178         rc = loc_category_get_svcs(cat_id, &svcs, &svcs_cnt);
    2179         if (rc != EOK || svcs_cnt == 0) {
    2180                 printf("%s: Failed to get visualizer category services.\n", NAME);
     2227                return rc;
     2228        }       
     2229
     2230        rc = discover_viewports();
     2231        if (rc != EOK) {
    21812232                input_disconnect();
    2182                 return -1;
    2183         }
    2184        
    2185         for (size_t i = 0; i < svcs_cnt; ++i) {
    2186                 char *svc_name;
    2187                 rc = loc_service_get_name(svcs[i], &svc_name);
    2188                 if (rc == EOK) {
    2189                         viewport_t *vp = viewport_create(svc_name);
    2190                         if (vp != NULL) {
    2191                                 list_append(&vp->link, &viewport_list);
    2192                         }
    2193                 }
     2233                return rc;
    21942234        }
    21952235       
     
    22032243        comp_damage(0, 0, UINT32_MAX, UINT32_MAX);
    22042244       
     2245       
    22052246        return EOK;
    22062247}
  • uspace/srv/net/dnsrsrv/dnsrsrv.c

    r95027b5 rb5ba8f6  
    6060        rc = transport_init();
    6161        if (rc != EOK) {
    62                 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing tarnsport.");
     62                log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing transport.");
    6363                return EIO;
    6464        }
  • uspace/srv/net/ethip/arp.c

    r95027b5 rb5ba8f6  
    9898    addr48_t mac_addr)
    9999{
     100        /* Broadcast address */
     101        if (ip_addr == addr32_broadcast_all_hosts) {
     102                addr48(addr48_broadcast, mac_addr);
     103                return EOK;
     104        }
     105
    100106        int rc = atrans_lookup(ip_addr, mac_addr);
    101107        if (rc == EOK)
  • uspace/srv/net/ethip/ethip_nic.c

    r95027b5 rb5ba8f6  
    202202        }
    203203
     204        rc = nic_broadcast_set_mode(nic->sess, NIC_BROADCAST_ACCEPTED);
     205        if (rc != EOK) {
     206                log_msg(LOG_DEFAULT, LVL_ERROR, "Error enabling "
     207                    "reception of broadcast frames on '%s'.", nic->svc_name);
     208                goto error;
     209        }
     210
    204211        log_msg(LOG_DEFAULT, LVL_DEBUG, "Initialized IP link service,");
    205212
  • uspace/srv/net/inetsrv/icmp.c

    r95027b5 rb5ba8f6  
    105105        reply->checksum = host2uint16_t_be(checksum);
    106106
     107        rdgram.iplink = 0;
    107108        rdgram.src = dgram->dest;
    108109        rdgram.dest = dgram->src;
     
    171172        inet_addr_set(sdu->dest, &dgram.dest);
    172173       
     174        dgram.iplink = 0;
    173175        dgram.tos = ICMP_TOS;
    174176        dgram.data = rdata;
  • uspace/srv/net/inetsrv/inet_link.c

    r95027b5 rb5ba8f6  
    235235        inet_addrobj_t *addr = NULL;
    236236       
     237        /* XXX FIXME Cannot rely on loopback being the first IP link service!! */
    237238        if (first_link) {
    238239                addr = inet_addrobj_new();
     
    240241                inet_naddr(&addr->naddr, 127, 0, 0, 1, 24);
    241242                first_link = false;
    242         } else {
    243                 /*
    244                  * FIXME
    245                  * Setting static IPv4 address for testing purposes:
    246                  * 10.0.2.15/24
    247                  */
    248                 addr = inet_addrobj_new();
    249                
    250                 inet_naddr(&addr->naddr, 10, 0, 2, 15, 24);
    251243        }
    252244       
  • uspace/srv/net/inetsrv/inetsrv.c

    r95027b5 rb5ba8f6  
    6868};
    6969
     70static inet_addr_t broadcast4_all_hosts = {
     71        .family = AF_INET,
     72        .addr = 0xffffffff
     73};
     74
    7075static inet_addr_t multicast_all_nodes = {
    7176        .family = AF_INET6,
     
    119124        }
    120125       
    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 
    132126        rc = inet_link_discovery_start();
    133127        if (rc != EOK)
     
    186180{
    187181        inet_dir_t dir;
     182        inet_link_t *ilink;
    188183        int rc;
     184
     185        if (dgram->iplink != 0) {
     186                log_msg(LOG_DEFAULT, LVL_DEBUG, "dgram directly to iplink %zu",
     187                    dgram->iplink);
     188                /* Send packet directly to the specified IP link */
     189                ilink = inet_link_get_by_id(dgram->iplink);
     190                if (ilink == 0)
     191                        return ENOENT;
     192
     193                if (dgram->src.family != AF_INET ||
     194                        dgram->dest.family != AF_INET)
     195                        return EINVAL;
     196
     197                return inet_link_send_dgram(ilink, dgram->src.addr,
     198                    dgram->dest.addr, dgram, proto, ttl, df);
     199        }
     200
     201        log_msg(LOG_DEFAULT, LVL_DEBUG, "dgram to be routed");
     202
     203        /* Route packet using source/destination addresses */
    189204
    190205        rc = inet_find_dir(&dgram->src, &dgram->dest, dgram->tos, &dir);
     
    214229
    215230        /* Take source address from the address object */
     231        if (remote->family == AF_INET && remote->addr == 0xffffffff) {
     232                local->family = AF_INET;
     233                local->addr = 0;
     234                return EOK;
     235        }
    216236        inet_naddr_addr(&dir.aobj->naddr, local);
    217237        return EOK;
     
    282302        inet_dgram_t dgram;
    283303       
    284         dgram.tos = IPC_GET_ARG1(*icall);
    285        
    286         uint8_t ttl = IPC_GET_ARG2(*icall);
     304        dgram.iplink = IPC_GET_ARG1(*icall);
     305        dgram.tos = IPC_GET_ARG2(*icall);
     306       
     307        uint8_t ttl = IPC_GET_ARG3(*icall);
    287308        int df = IPC_GET_ARG3(*icall);
    288309       
     
    524545        if ((addr != NULL) ||
    525546            (inet_naddr_compare_mask(&solicited_node_mask, &packet->dest)) ||
    526             (inet_addr_compare(&multicast_all_nodes, &packet->dest))) {
     547            (inet_addr_compare(&multicast_all_nodes, &packet->dest)) ||
     548            (inet_addr_compare(&broadcast4_all_hosts, &packet->dest))) {
    527549                /* Destined for one of the local addresses */
    528550
  • uspace/srv/net/inetsrv/inetsrv.h

    r95027b5 rb5ba8f6  
    127127
    128128typedef struct {
     129        service_id_t iplink;
    129130        inet_addr_t src;
    130131        inet_addr_t dest;
  • uspace/srv/net/slip/slip.c

    r95027b5 rb5ba8f6  
    333333                    "Failed to connect to service %s (ID=%d)",
    334334                    svcstr, (int) svcid);
    335                 return rc;
     335                return ENOENT;
    336336        }
    337337        slip_iplink.arg = sess_out;
     
    342342                    "Failed to connect to service %s (ID=%d)",
    343343                    svcstr, (int) svcid);
     344                rc = ENOENT;
    344345                goto fail;
    345346        }
     
    365366                log_msg(LOG_DEFAULT, LVL_ERROR,
    366367                    "Failed to create receive fibril.");
     368                rc = ENOENT;
    367369                goto fail;
    368370        }
  • uspace/srv/net/tcp/tcp.c

    r95027b5 rb5ba8f6  
    141141            pdu->text_size);
    142142
     143        dgram.iplink = 0;
    143144        dgram.src = pdu->src;
    144145        dgram.dest = pdu->dest;
  • uspace/srv/net/udp/assoc.c

    r95027b5 rb5ba8f6  
    184184        fibril_mutex_unlock(&assoc_list_lock);
    185185        udp_assoc_delref(assoc);
     186}
     187
     188/** Set IP link in association.
     189 *
     190 * @param assoc         Association
     191 * @param iplink        IP link
     192 */
     193void udp_assoc_set_iplink(udp_assoc_t *assoc, service_id_t iplink)
     194{
     195        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_set_iplink(%p, %zu)",
     196            assoc, iplink);
     197        fibril_mutex_lock(&assoc->lock);
     198        assoc->ident.iplink = iplink;
     199        fibril_mutex_unlock(&assoc->lock);
    186200}
    187201
  • uspace/srv/net/udp/assoc.h

    r95027b5 rb5ba8f6  
    3636#define ASSOC_H
    3737
     38#include <ipc/loc.h>
    3839#include <sys/types.h>
    3940#include "udp_type.h"
     
    4546extern void udp_assoc_addref(udp_assoc_t *);
    4647extern void udp_assoc_delref(udp_assoc_t *);
     48extern void udp_assoc_set_iplink(udp_assoc_t *, service_id_t);
    4749extern void udp_assoc_set_foreign(udp_assoc_t *, udp_sock_t *);
    4850extern void udp_assoc_set_local(udp_assoc_t *, udp_sock_t *);
  • uspace/srv/net/udp/pdu.c

    r95027b5 rb5ba8f6  
    215215                return ENOMEM;
    216216
     217        npdu->iplink = sp->iplink;
    217218        npdu->src = sp->local.addr;
    218219        npdu->dest = sp->foreign.addr;
  • uspace/srv/net/udp/sock.c

    r95027b5 rb5ba8f6  
    11/*
    22 * Copyright (c) 2008 Lukas Mejdrech
    3  * Copyright (c) 2012 Jiri Svoboda
     3 * Copyright (c) 2013 Jiri Svoboda
    44 * All rights reserved.
    55 *
     
    349349        fibril_mutex_lock(&socket->lock);
    350350       
    351         if (inet_addr_is_any(&socket->assoc->ident.local.addr)) {
     351        if (inet_addr_is_any(&socket->assoc->ident.local.addr) &&
     352                socket->assoc->ident.iplink == 0) {
    352353                /* Determine local IP address */
    353354                inet_addr_t loc_addr;
     
    665666static void udp_sock_setsockopt(udp_client_t *client, ipc_callid_t callid, ipc_call_t call)
    666667{
    667         log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_setsockopt()");
    668         async_answer_0(callid, ENOTSUP);
    669 }
     668        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_setsockopt)");
     669        log_msg(LOG_DEFAULT, LVL_DEBUG, " - async_data_write_accept");
     670       
     671        void *data = NULL;
     672        size_t data_len;
     673        int rc = async_data_write_accept(&data, false, 0, 0, 0, &data_len);
     674        if (rc != EOK) {
     675                log_msg(LOG_DEFAULT, LVL_DEBUG, " - failed accepting data");
     676                async_answer_0(callid, rc);
     677                return;
     678        }
     679       
     680        sysarg_t opt_level = SOL_SOCKET;
     681        sysarg_t opt_name = SOCKET_GET_OPT_NAME(call);
     682       
     683        if (opt_level != SOL_SOCKET || opt_name != SO_IPLINK ||
     684            data_len != sizeof(service_id_t)) {
     685                log_msg(LOG_DEFAULT, LVL_DEBUG, " - failed opt_level/name/len");
     686                log_msg(LOG_DEFAULT, LVL_DEBUG, " - failed opt_level=%d, "
     687                    "opt_name=%d, data_len=%zu", (int)opt_level, (int)opt_name,
     688                    data_len);
     689                async_answer_0(callid, EINVAL);
     690                return;
     691        }
     692       
     693        log_msg(LOG_DEFAULT, LVL_DEBUG, " - call socket_cores_find");
     694       
     695        socket_core_t *sock_core = socket_cores_find(&client->sockets,
     696            SOCKET_GET_SOCKET_ID(call));
     697        if (sock_core == NULL) {
     698                log_msg(LOG_DEFAULT, LVL_DEBUG, " - failed getting sock_core");
     699                async_answer_0(callid, ENOENT);
     700                return;
     701        }
     702       
     703        udp_sockdata_t *socket =
     704            (udp_sockdata_t *) sock_core->specific_data;
     705       
     706        service_id_t iplink = *(service_id_t *)data;
     707        udp_uc_set_iplink(socket->assoc, iplink);
     708       
     709        log_msg(LOG_DEFAULT, LVL_DEBUG, " - success");
     710        async_answer_0(callid, EOK);
     711}
     712
    670713
    671714static int udp_sock_recv_fibril(void *arg)
     
    714757
    715758        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() exited loop");
    716         fibril_mutex_unlock(&sock->recv_buffer_lock);
    717759        udp_uc_destroy(sock->assoc);
    718760
     
    730772        /* Accept the connection */
    731773        async_answer_0(iid, EOK);
     774
     775        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_connection: begin");
    732776
    733777        client.sess = async_callback_receive(EXCHANGE_SERIALIZE);
  • uspace/srv/net/udp/ucall.c

    r95027b5 rb5ba8f6  
    5555        *assoc = nassoc;
    5656        return UDP_EOK;
     57}
     58
     59void udp_uc_set_iplink(udp_assoc_t *assoc, service_id_t iplink)
     60{
     61        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_uc_set_iplink(%p, %zu)",
     62            assoc, iplink);
     63
     64        udp_assoc_set_iplink(assoc, iplink);
    5765}
    5866
  • uspace/srv/net/udp/ucall.h

    r95027b5 rb5ba8f6  
    3636#define UCALL_H
    3737
     38#include <ipc/loc.h>
    3839#include <sys/types.h>
    3940#include "udp_type.h"
    4041
    4142extern udp_error_t udp_uc_create(udp_assoc_t **);
     43extern void udp_uc_set_iplink(udp_assoc_t *, service_id_t);
    4244extern udp_error_t udp_uc_set_foreign(udp_assoc_t *, udp_sock_t *);
    4345extern udp_error_t udp_uc_set_local(udp_assoc_t *, udp_sock_t *);
  • uspace/srv/net/udp/udp_inet.c

    r95027b5 rb5ba8f6  
    8484        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_transmit_pdu()");
    8585
     86        dgram.iplink = pdu->iplink;
    8687        dgram.src = pdu->src;
    8788        dgram.dest = pdu->dest;
  • uspace/srv/net/udp/udp_type.h

    r95027b5 rb5ba8f6  
    3838#include <fibril.h>
    3939#include <fibril_synch.h>
     40#include <ipc/loc.h>
    4041#include <socket_core.h>
    4142#include <sys/types.h>
     
    7172
    7273typedef struct {
     74        service_id_t iplink;
    7375        udp_sock_t local;
    7476        udp_sock_t foreign;
     
    8587/** Encoded PDU */
    8688typedef struct {
     89        /** IP link (optional) */
     90        service_id_t iplink;
    8791        /** Source address */
    8892        inet_addr_t src;
    8993        /** Destination address */
    9094        inet_addr_t dest;
    91        
    9295        /** Encoded PDU data including header */
    9396        void *data;
     
    143146        /** Connection */
    144147        udp_assoc_t *assoc;
     148        /** User-configured IP link */
     149        service_id_t iplink;
    145150        /** Receiving fibril */
    146151        fid_t recv_fibril;
Note: See TracChangeset for help on using the changeset viewer.