Changes in / [b9f7848b:5ed8b72] in mainline


Ignore:
Location:
uspace
Files:
2 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/inet/inet.c

    rb9f7848b r5ed8b72  
    312312}
    313313
    314 static int link_list(void)
    315 {
    316         sysarg_t *link_list;
    317         inet_link_info_t linfo;
    318 
    319         size_t count;
    320         size_t i;
    321         int rc;
    322 
    323         rc = inetcfg_get_link_list(&link_list, &count);
    324         if (rc != EOK) {
    325                 printf(NAME ": Failed getting link list.\n");
    326                 return rc;
    327         }
    328 
    329         printf("IP links:\n");
    330         if (count > 0)
    331                 printf("    [Link-layer Address] [Link-Name] [Def-MTU]\n");
    332 
    333         for (i = 0; i < count; i++) {
    334                 rc = inetcfg_link_get(link_list[i], &linfo);
    335                 if (rc != EOK) {
    336                         printf("Failed getting properties of link %zu.\n",
    337                             (size_t)link_list[i]);
    338                         continue;
    339                 }
    340 
    341                 printf("    %02x:%02x:%02x:%02x:%02x:%02x %s %zu\n",
    342                     linfo.mac_addr[0], linfo.mac_addr[1],
    343                     linfo.mac_addr[2], linfo.mac_addr[3],
    344                     linfo.mac_addr[4], linfo.mac_addr[5],
    345                     linfo.name, linfo.def_mtu);
    346 
    347                 free(linfo.name);
    348 
    349                 linfo.name = NULL;
    350         }
    351 
    352         if (count == 0)
    353                 printf("    None\n");
    354 
    355         free(link_list);
    356 
    357         return EOK;
    358 }
    359 
    360314static int sroute_list(void)
    361315{
     
    450404                if (rc != EOK)
    451405                        return 1;
    452                 rc = link_list();
    453                 if (rc != EOK)
    454                         return 1;
    455406                return 0;
    456407        }
  • uspace/lib/c/generic/inetcfg.c

    rb9f7848b r5ed8b72  
    279279        aid_t req = async_send_1(exch, INETCFG_LINK_GET, link_id, &answer);
    280280        aid_t dreq = async_data_read(exch, name_buf, LOC_NAME_MAXLEN, &dreply);
    281         int rc = async_data_read_start(exch, &linfo->mac_addr, sizeof(addr48_t));
    282281        async_wait_for(dreq, &dretval);
    283282
    284283        async_exchange_end(exch);
    285284
    286         if (dretval != EOK || rc != EOK) {
     285        if (dretval != EOK) {
    287286                async_forget(req);
    288287                return dretval;
  • uspace/lib/c/include/inet/inet.h

    rb9f7848b r5ed8b72  
    3939#include <ipc/loc.h>
    4040#include <sys/types.h>
    41 #include <types/inet.h>
     41
     42#define INET_TTL_MAX 255
     43
     44typedef struct {
     45        /** Local IP link service ID (optional) */
     46        service_id_t iplink;
     47        inet_addr_t src;
     48        inet_addr_t dest;
     49        uint8_t tos;
     50        void *data;
     51        size_t size;
     52} inet_dgram_t;
     53
     54typedef struct {
     55        int (*recv)(inet_dgram_t *);
     56} inet_ev_ops_t;
     57
     58typedef enum {
     59        INET_DF = 1
     60} inet_df_t;
    4261
    4362extern int inet_init(uint8_t, inet_ev_ops_t *);
  • uspace/lib/c/include/inet/inetcfg.h

    rb9f7848b r5ed8b72  
    3838#include <inet/inet.h>
    3939#include <sys/types.h>
    40 #include <types/inetcfg.h>
     40
     41/** Address object info */
     42typedef struct {
     43        /** Network address */
     44        inet_naddr_t naddr;
     45        /** Link service ID */
     46        sysarg_t ilink;
     47        /** Address object name */
     48        char *name;
     49} inet_addr_info_t;
     50
     51/** IP link info */
     52typedef struct {
     53        /** Link service name */
     54        char *name;
     55        /** Default MTU */
     56        size_t def_mtu;
     57} inet_link_info_t;
     58
     59/** Static route info */
     60typedef struct {
     61        /** Destination network address */
     62        inet_naddr_t dest;
     63        /** Router address */
     64        inet_addr_t router;
     65        /** Static route name */
     66        char *name;
     67} inet_sroute_info_t;
    4168
    4269extern int inetcfg_init(void);
  • uspace/srv/net/dhcp/dhcp.c

    rb9f7848b r5ed8b72  
    5353
    5454static int transport_fd = -1;
    55 static inet_link_info_t link_info;
     55static addr48_t mac_addr;
    5656static uint8_t msgbuf[MAX_MSG_SIZE];
    5757
     
    132132        hdr->flags = flag_broadcast;
    133133
    134         addr48(link_info.mac_addr, hdr->chaddr);
     134        addr48(mac_addr, hdr->chaddr);
    135135        hdr->opt_magic = host2uint32_t_be(dhcp_opt_magic);
    136136
     
    178178        hdr->flags = flag_broadcast;
    179179        hdr->ciaddr = host2uint32_t_be(offer->oaddr.addr);
    180         addr48(link_info.mac_addr, hdr->chaddr);
     180        addr48(mac_addr, hdr->chaddr);
    181181        hdr->opt_magic = host2uint32_t_be(dhcp_opt_magic);
    182182
     
    387387                rc = dnsr_set_srvaddr(&offer->dns_server);
    388388                if (rc != EOK) {
    389                         printf("%s: Error setting nameserver address (%d))\n",
     389                        printf("%s: Failed setting nameserver address (%d))\n",
    390390                            NAME, rc);
    391391                        return rc;
     
    413413        rc = inetcfg_init();
    414414        if (rc != EOK) {
    415                 printf("Error contacting inet configuration service.\n");
     415                printf("Failed contacting inet configuration service.\n");
    416416                return 1;
    417417        }
     
    419419        rc = loc_service_get_id(argv[1], &iplink, 0);
    420420        if (rc != EOK) {
    421                 printf("Error resolving service '%s'.\n", argv[1]);
    422                 return 1;
    423         }
    424 
    425         /* Get link hardware address */
    426         rc = inetcfg_link_get(iplink, &link_info);
    427         if (rc != EOK) {
    428                 printf("Error getting properties for link '%s'.\n", argv[1]);
    429                 return 1;
    430         }
     421                printf("Failed resolving service '%s'.\n", argv[1]);
     422                return 1;
     423        }
     424
     425        /* XXX Determine MAC address automatically */
     426        mac_addr[0] = 0xaa;
     427        mac_addr[1] = 0xde;
     428        mac_addr[2] = 0xad;
     429        mac_addr[3] = 0xbe;
     430        mac_addr[4] = 0xef;
     431        mac_addr[5] = 0xfe;
    431432
    432433        laddr.sin_family = AF_INET;
  • uspace/srv/net/inetsrv/inet_link.c

    rb9f7848b r5ed8b72  
    493493}
    494494
    495 /** Get IDs of all links. */
    496 int inet_link_get_id_list(sysarg_t **rid_list, size_t *rcount)
    497 {
    498         sysarg_t *id_list;
    499         size_t count, i;
    500 
    501         fibril_mutex_lock(&inet_discovery_lock);
    502         count = list_count(&inet_link_list);
    503 
    504         id_list = calloc(count, sizeof(sysarg_t));
    505         if (id_list == NULL) {
    506                 fibril_mutex_unlock(&inet_discovery_lock);
    507                 return ENOMEM;
    508         }
    509 
    510         i = 0;
    511         list_foreach(inet_link_list, link_list, inet_link_t, ilink) {
    512                 id_list[i++] = ilink->svc_id;
    513                 log_msg(LOG_DEFAULT, LVL_NOTE, "add link to list");
    514         }
    515 
    516         fibril_mutex_unlock(&inet_discovery_lock);
    517 
    518         log_msg(LOG_DEFAULT, LVL_NOTE, "return %zu links", count);
    519         *rid_list = id_list;
    520         *rcount = count;
    521 
    522         return EOK;
    523 }
    524 
    525495/** @}
    526496 */
  • uspace/srv/net/inetsrv/inet_link.h

    rb9f7848b r5ed8b72  
    4747    uint8_t, uint8_t, int);
    4848extern inet_link_t *inet_link_get_by_id(sysarg_t);
    49 extern int inet_link_get_id_list(sysarg_t **, size_t *);
    5049
    5150#endif
  • uspace/srv/net/inetsrv/inetcfg.c

    rb9f7848b r5ed8b72  
    4444#include <str.h>
    4545#include <sys/types.h>
    46 #include <types/inetcfg.h>
    4746
    4847#include "addrobj.h"
     
    152151static int inetcfg_get_link_list(sysarg_t **addrs, size_t *count)
    153152{
    154         return inet_link_get_id_list(addrs, count);
     153        return ENOTSUP;
    155154}
    156155
     
    171170        linfo->name = str_dup(ilink->svc_name);
    172171        linfo->def_mtu = ilink->def_mtu;
    173         if (ilink->mac_valid) {
    174                 addr48(ilink->mac, linfo->mac_addr);
    175         } else {
    176                 memset(linfo->mac_addr, 0, sizeof(linfo->mac_addr));
    177         }
    178 
    179172        return EOK;
    180173}
     
    418411{
    419412        ipc_callid_t rcallid;
    420         size_t count;
    421413        size_t max_size;
    422414        size_t act_size;
     
    425417        int rc;
    426418
    427         log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_get_addr_list_srv()");
     419        log_msg(LOG_DEFAULT, LVL_DEBUG, "inetcfg_get_link_list_srv()");
    428420
    429421        if (!async_data_read_receive(&rcallid, &max_size)) {
     
    433425        }
    434426
    435         rc = inetcfg_get_link_list(&id_buf, &count);
     427        rc = inetcfg_get_link_list(&id_buf, &act_size);
    436428        if (rc != EOK) {
    437429                async_answer_0(rcallid, rc);
     
    440432        }
    441433
    442         act_size = count * sizeof(sysarg_t);
    443434        size = min(act_size, max_size);
    444435
     
    485476static void inetcfg_link_get_srv(ipc_callid_t callid, ipc_call_t *call)
    486477{
    487         ipc_callid_t name_callid;
    488         ipc_callid_t laddr_callid;
    489         size_t name_max_size;
    490         size_t laddr_max_size;
     478        ipc_callid_t rcallid;
     479        size_t max_size;
    491480
    492481        sysarg_t link_id;
     
    499488        linfo.name = NULL;
    500489
    501         if (!async_data_read_receive(&name_callid, &name_max_size)) {
    502                 async_answer_0(name_callid, EREFUSED);
    503                 async_answer_0(callid, EREFUSED);
    504                 return;
    505         }
    506 
    507         if (!async_data_read_receive(&laddr_callid, &laddr_max_size)) {
    508                 async_answer_0(name_callid, EREFUSED);
     490        if (!async_data_read_receive(&rcallid, &max_size)) {
     491                async_answer_0(rcallid, EREFUSED);
    509492                async_answer_0(callid, EREFUSED);
    510493                return;
     
    513496        rc = inetcfg_link_get(link_id, &linfo);
    514497        if (rc != EOK) {
    515                 async_answer_0(laddr_callid, rc);
    516                 async_answer_0(name_callid, rc);
    517                 async_answer_0(callid, rc);
    518                 return;
    519         }
    520 
    521         sysarg_t retval = async_data_read_finalize(name_callid, linfo.name,
    522             min(name_max_size, str_size(linfo.name)));
    523         if (retval != EOK) {
    524                 free(linfo.name);
    525                 async_answer_0(laddr_callid, retval);
    526                 async_answer_0(callid, retval);
    527                 return;
    528         }
    529 
    530         retval = async_data_read_finalize(laddr_callid, &linfo.mac_addr,
    531             min(laddr_max_size, sizeof(linfo.mac_addr)));
    532 
     498                async_answer_0(rcallid, rc);
     499                async_answer_0(callid, rc);
     500                return;
     501        }
     502
     503        sysarg_t retval = async_data_read_finalize(rcallid, linfo.name,
     504            min(max_size, str_size(linfo.name)));
    533505        free(linfo.name);
    534506
  • uspace/srv/net/inetsrv/inetsrv.h

    rb9f7848b r5ed8b72  
    4444#include <ipc/loc.h>
    4545#include <sys/types.h>
    46 #include <types/inet.h>
    4746#include <async.h>
    4847
     
    7372        link_t client_list;
    7473} inetping6_client_t;
     74
     75/** Address object info */
     76typedef struct {
     77        /** Network address */
     78        inet_naddr_t naddr;
     79        /** Link service ID */
     80        sysarg_t ilink;
     81        /** Address object name */
     82        char *name;
     83} inet_addr_info_t;
     84
     85/** IP link info */
     86typedef struct {
     87        /** Link service name */
     88        char *name;
     89        /** Default MTU */
     90        size_t def_mtu;
     91} inet_link_info_t;
     92
     93/** Static route info */
     94typedef struct {
     95        /** Destination network address */
     96        inet_naddr_t dest;
     97        /** Router address */
     98        inet_addr_t router;
     99        /** Static route name */
     100        char *name;
     101} inet_sroute_info_t;
    75102
    76103typedef struct {
     
    100127
    101128typedef struct {
     129        service_id_t iplink;
     130        inet_addr_t src;
     131        inet_addr_t dest;
     132        uint8_t tos;
     133        void *data;
     134        size_t size;
     135} inet_dgram_t;
     136
     137typedef struct {
    102138        link_t link_list;
    103139        service_id_t svc_id;
Note: See TracChangeset for help on using the changeset viewer.