Changeset 1333dfc in mainline


Ignore:
Timestamp:
2024-12-13T08:44:05Z (10 months ago)
Author:
Nataliia Korop <n.corop08@…>
Children:
0210d42d
Parents:
fc2d593
git-author:
Nataliia Korop <n.corop08@…> (2024-04-11 09:36:03)
git-committer:
Nataliia Korop <n.corop08@…> (2024-12-13 08:44:05)
Message:

inetsrv dumps

Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/nic/src/nic_driver.c

    rfc2d593 r1333dfc  
    523523         *               calls it inside send_frame handler (with locked main lock)
    524524         */
    525         pcapdump_packet(nic_get_pcap_iface(nic_data), frame->data, frame->size);
     525        //pcapdump_packet(nic_get_pcap_iface(nic_data), frame->data, frame->size);
    526526        fibril_rwlock_read_lock(&nic_data->rxc_lock);
    527527        nic_frame_type_t frame_type;
     
    651651        nic_data->dev = device;
    652652
    653         errno_t pcap_rc  = pcapdump_init(nic_get_pcap_iface(nic_data));
    654         if (pcap_rc != EOK) {
    655                 printf("Failed creating pcapdump port\n");
    656         }
     653        // errno_t pcap_rc  = pcapdump_init(nic_get_pcap_iface(nic_data));
     654        // if (pcap_rc != EOK) {
     655        //      printf("Failed creating pcapdump port\n");
     656        // }
    657657
    658658        return nic_data;
  • uspace/lib/nic/src/nic_impl.c

    rfc2d593 r1333dfc  
    850850        if (rc != EOK)
    851851                return rc;
    852 
    853         rc = ddf_fun_add_to_category(fun, "pcap");
    854         if (rc != EOK) {
    855852                return rc;
    856         }
     853
     854        // rc = ddf_fun_add_to_category(fun, "pcap");
     855        // if (rc != EOK) {
     856        //      return rc;
     857        // }
    857858        return EOK;
    858859}
  • uspace/lib/pcap/src/pcapctl_dump.c

    rfc2d593 r1333dfc  
    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 }
     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// }
    8181
    8282errno_t pcapctl_is_valid_device(int *index)
     
    149149                return ENOMEM;
    150150
    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 
     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;
    169160
    170161        async_sess_t *new_session = loc_service_connect(svc, INTERFACE_PCAP_CONTROL, 0);
     
    174165                goto error;
    175166        }
    176 
     167        printf("got new session\n");
    177168        sess->sess = new_session;
    178169        *rsess = sess;
     
    200191errno_t pcapctl_dump_start(const char *name, pcapctl_sess_t *sess)
    201192{
     193        printf("pcapctl_dump_start\n");
    202194        errno_t rc;
    203195        async_exch_t *exch = async_exchange_begin(sess->sess);
  • uspace/srv/net/inetsrv/inetsrv.c

    rfc2d593 r1333dfc  
    4949#include <stdint.h>
    5050#include <task.h>
     51#include <pcapdump_iface.h>
    5152#include "addrobj.h"
    5253#include "icmp.h"
     
    6364#define NAME "inetsrv"
    6465
     66/** Interface for dumping packets */
     67pcap_iface_t pcapdump;
    6568
    6669static inet_naddr_t solicited_node_mask = {
     
    118121        if (rc != EOK)
    119122                return rc;
    120 
     123        rc = async_create_port(INTERFACE_PCAP_CONTROL,
     124            pcapdump_conn, &pcapdump, &port);
     125        if (rc != EOK) {
     126                return rc;
     127        }
    121128        rc = loc_server_register(NAME, &srv);
    122129        if (rc != EOK) {
     
    203210                    dgram->dest.addr, dgram, proto, ttl, df);
    204211        }
    205 
     212        printf("SENDING: packet size is - %d\n", dgram->size);
     213        pcapdump_packet(&pcapdump, dgram->data, dgram->size);
    206214        log_msg(LOG_DEFAULT, LVL_DEBUG, "dgram to be routed");
    207215
     
    541549                        dgram.data = packet->data;
    542550                        dgram.size = packet->size;
     551                        printf("RECEIVING: packet size is - %d\n", packet->size);
     552                        pcapdump_packet(&pcapdump, packet->data, packet->size);
    543553                        return inet_recv_dgram_local(&dgram, packet->proto);
    544554                } else {
     
    561571                return 1;
    562572        }
    563 
     573        rc = pcap_iface_init(&pcapdump);
     574
     575        if (rc != EOK) {
     576                printf("Failed creating pcap interface: %s", str_error(rc));
     577                return rc;
     578        }
    564579        rc = inet_init();
    565580        if (rc != EOK)
    566581                return 1;
    567582
     583        printf(NAME ": Initialized dump iface from inetsrv.\n");
    568584        printf(NAME ": Accepting connections.\n");
    569585
Note: See TracChangeset for help on using the changeset viewer.