Changeset 0210d42d in mainline for uspace/lib/pcap/src/pcapctl_dump.c


Ignore:
Timestamp:
2024-12-13T08:44:05Z (10 months ago)
Author:
Nataliia Korop <n.corop08@…>
Children:
59fe16d
Parents:
1333dfc
git-author:
Nataliia Korop <n.corop08@…> (2024-05-08 13:47:52)
git-committer:
Nataliia Korop <n.corop08@…> (2024-12-13 08:44:05)
Message:

ethip/drvs can dump, default ethip

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/pcap/src/pcapctl_dump.c

    r1333dfc r0210d42d  
    5252}
    5353
    54 // static errno_t pcapctl_cat_get_svc(int *index, service_id_t *svc)
    55 // {
    56 //      errno_t rc;
    57 //      category_id_t pcap_cat;
    58 //      size_t count;
    59 //      service_id_t *pcap_svcs = NULL;
    60 
    61 //      rc = loc_category_get_id("pcap", &pcap_cat, 0);
    62 //      if (rc != EOK) {
    63 //              printf("Error resolving category 'pcap'.\n");
    64 //              return rc;
    65 //      }
    66 
    67 //      rc = loc_category_get_svcs(pcap_cat, &pcap_svcs, &count);
    68 //      if (rc != EOK) {
    69 //              printf("Error resolving list of pcap services.\n");
    70 //              free(pcap_svcs);
    71 //              return rc;
    72 //      }
    73 //      if (*index < (int)count) {
    74 //              *svc =  pcap_svcs[*index];
    75 //              free(pcap_svcs);
    76 //              return EOK;
    77 //      }
    78 
    79 //      return ENOENT;
    80 // }
     54static errno_t pcapctl_cat_get_svc(int *index, service_id_t *svc)
     55{
     56        errno_t rc;
     57        category_id_t pcap_cat;
     58        size_t count;
     59        service_id_t *pcap_svcs = NULL;
     60
     61        rc = loc_category_get_id("pcap", &pcap_cat, 0);
     62        if (rc != EOK) {
     63                printf("Error resolving category 'pcap'.\n");
     64                return rc;
     65        }
     66
     67        rc = loc_category_get_svcs(pcap_cat, &pcap_svcs, &count);
     68        if (rc != EOK) {
     69                printf("Error resolving list of pcap services.\n");
     70                free(pcap_svcs);
     71                return rc;
     72        }
     73        if (*index < (int)count) {
     74                *svc =  pcap_svcs[*index];
     75                free(pcap_svcs);
     76                return EOK;
     77        }
     78
     79        return ENOENT;
     80}
    8181
    8282errno_t pcapctl_is_valid_device(int *index)
     
    149149                return ENOMEM;
    150150
    151         // rc  = pcapctl_cat_get_svc(index, &svc);
    152         // if (rc != EOK) {
    153         //      printf("Error finding the device with index: %d\n", *index);
    154         //      goto error;
    155         // }
    156 
    157         rc = loc_service_get_id("net/inet", &svc, 0);
    158         if (rc != EOK)
    159                 return ENOENT;
     151        printf("number: %d\n", *index);
     152        if (*index == -1) {
     153
     154                rc = loc_service_get_id("net/eth1", &svc, 0);
     155                if (rc != EOK)
     156                {
     157                        fprintf(stderr, "Error getting service id.\n");
     158                        return ENOENT;
     159                }
     160        }
     161        else {
     162                rc  = pcapctl_cat_get_svc(index, &svc);
     163                if (rc != EOK) {
     164                        printf("Error finding the device with index: %d\n", *index);
     165                        goto error;
     166                }
     167        }
     168
    160169
    161170        async_sess_t *new_session = loc_service_connect(svc, INTERFACE_PCAP_CONTROL, 0);
     
    165174                goto error;
    166175        }
    167         printf("got new session\n");
     176
    168177        sess->sess = new_session;
    169178        *rsess = sess;
     
    191200errno_t pcapctl_dump_start(const char *name, pcapctl_sess_t *sess)
    192201{
    193         printf("pcapctl_dump_start\n");
    194202        errno_t rc;
    195203        async_exch_t *exch = async_exchange_begin(sess->sess);
Note: See TracChangeset for help on using the changeset viewer.