Changeset 6eab537d in mainline


Ignore:
Timestamp:
2024-03-10T09:38:44Z (8 weeks ago)
Author:
Nataliia Korop <n.corop08@…>
Children:
e846bec
Parents:
192019f
Message:

moved to nic, fixed all except addressing

Location:
uspace
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/pcapctl/main.c

    r192019f r6eab537d  
    4040
    4141#define NAME "pcapctl"
    42 
    43 #define LOGGER(msg, ...) \
    44      fprintf(stderr, \
    45          "[PCAP %s:%d]: " msg "\n", \
    46          __FILE__, __LINE__, \
    47          ##__VA_ARGS__\
    48      )
    4942
    5043pcapctl_sess_t sess;
  • uspace/drv/nic/e1k/e1k.c

    r192019f r6eab537d  
    4949#include <nic.h>
    5050#include <ops/nic.h>
     51#include <pcapdump_iface.h>
    5152#include "e1k.h"
    5253
    53 #include "pcapdump_iface.h"
    54 #include "pcap_iface.h"
    5554#define NAME  "e1k"
    5655
     
    11921191                if (frame != NULL) {
    11931192                        memcpy(frame->data, e1000->rx_frame_virt[next_tail], frame_size);
    1194                         pcapdump_packet(nic_get_pcap_iface(nic), frame->data, frame->size);
    11951193
    11961194                        nic_received_frame(nic, frame);
     
    22082206                goto err_add_to_cat;
    22092207
    2210         errno_t pcap_rc  = pcapdump_init(nic_get_pcap_iface(nic));
    2211 
    2212         if (pcap_rc != EOK) {
    2213                 printf("Failed creating pcapdump port\n");
    2214         }
    22152208        rc = ddf_fun_add_to_category(fun, "pcap");
    2216         if (rc != EOK)
     2209        if (rc != EOK) {
     2210                ddf_msg(LVL_ERROR, "Failed adding function to category pcap");
    22172211                goto err_add_to_cat;
     2212        }
    22182213
    22192214        return EOK;
     
    23802375
    23812376        memcpy(e1000->tx_frame_virt[tdt], data, size);
    2382         pcapdump_packet(nic_get_pcap_iface(nic), data, size);
    23832377        tx_descriptor_addr->phys_addr = PTR_TO_U64(e1000->tx_frame_phys[tdt]);
    23842378        tx_descriptor_addr->length = size;
  • uspace/drv/nic/virtio-net/virtio-net.c

    r192019f r6eab537d  
    4343
    4444#include <virtio-pci.h>
    45 #include "pcapdump_iface.h"
    46 #include "pcap_iface.h"
     45#include <pcapdump_iface.h>
     46
    4747#define NAME    "virtio-net"
    4848
     
    9393                if (frame) {
    9494                        memcpy(frame->data, &hdr[1], len - sizeof(*hdr));
    95                         pcapdump_packet(nic_get_pcap_iface(nic), frame->data, frame->size);
    9695                        nic_received_frame(nic, frame);
    9796                } else {
     
    353352        /* Copy packet data into the buffer just past the header */
    354353        memcpy(&hdr[1], data, size);
    355         pcapdump_packet(nic_get_pcap_iface(nic), data, size);
     354
    356355        /*
    357356         * Set the descriptor, put it into the virtqueue and notify the device
     
    433432            ddf_dev_get_name(dev));
    434433
    435         errno_t pcap_rc  = pcapdump_init(nic_get_pcap_iface(nic));
    436 
    437         if (pcap_rc != EOK) {
    438                 printf("Failed creating pcapdump port\n");
    439         }
    440434        rc = ddf_fun_add_to_category(fun, "pcap");
    441         if (rc != EOK)
     435        if (rc != EOK) {
     436                ddf_msg(LVL_ERROR, "Failed adding function to category pcap");
    442437                goto unbind;
     438        }
    443439
    444440        return EOK;
  • uspace/lib/nic/include/nic.h

    r192019f r6eab537d  
    4444#include <device/hw_res_parsed.h>
    4545#include <ops/nic.h>
    46 
    47 #include "pcap_iface.h"
     46#include <pcap_iface.h>
    4847
    4948#define DEVICE_CATEGORY_NIC "nic"
  • uspace/lib/nic/src/nic_driver.c

    r192019f r6eab537d  
    4747#include <ops/nic.h>
    4848#include <errno.h>
     49#include <pcapdump_iface.h>
    4950
    5051#include "nic_driver.h"
     
    522523         *               calls it inside send_frame handler (with locked main lock)
    523524         */
     525        pcapdump_packet(nic_get_pcap_iface(nic_data), frame->data, frame->size);
    524526        fibril_rwlock_read_lock(&nic_data->rxc_lock);
    525527        nic_frame_type_t frame_type;
     
    560562                fibril_rwlock_write_unlock(&nic_data->stats_lock);
    561563        }
     564        //pcapdump_packet(nic_get_pcap_iface(nic_data), frame->data, frame->size);
    562565        nic_release_frame(nic_data, frame);
    563566}
     
    647650
    648651        nic_data->dev = device;
     652        errno_t pcap_rc  = pcapdump_init(nic_get_pcap_iface(nic_data));
     653
     654        if (pcap_rc != EOK) {
     655                printf("Failed creating pcapdump port\n");
     656        }
    649657
    650658        return nic_data;
  • uspace/lib/nic/src/nic_impl.c

    r192019f r6eab537d  
    4040#include <ipc/services.h>
    4141#include <ns.h>
     42#include <pcapdump_iface.h>
    4243#include "nic_driver.h"
    4344#include "nic_ev.h"
     
    179180                return EBUSY;
    180181        }
    181 
     182        pcapdump_packet(nic_get_pcap_iface(nic_data), data, size);
    182183        nic_data->send_frame(nic_data, data, size);
    183184        fibril_rwlock_read_unlock(&nic_data->main_lock);
  • uspace/lib/pcap/include/pcap.h

    r192019f r6eab537d  
    6464        uint32_t snaplen;
    6565        uint32_t additional; /** The LinkType and additional information field is in the form */
    66 } __attribute__((packed, aligned(4))) pcap_file_header_t;
     66} pcap_file_header_t;
    6767
    6868typedef struct pcap_packet_header {
  • uspace/lib/pcap/src/pcap.c

    r192019f r6eab537d  
    3535 * @brief Headers and functions for .pcap file and packets to be dumped
    3636 */
    37 
    38 #define LOGGER(msg, ...) \
    39      fprintf(stderr, \
    40          "[PCAP %s:%d]: " msg "\n", \
    41          __FILE__, __LINE__, \
    42          ##__VA_ARGS__\
    43      )
    4437
    4538#include "pcap.h"
     
    108101        if (writer->data == NULL) {
    109102                rc = EINVAL;
    110                 LOGGER("Failed to create %s: %s.", filename, str_error(rc));
    111103                return rc;
    112104        }
  • uspace/lib/pcap/src/pcap_iface.c

    r192019f r6eab537d  
    8282}
    8383
    84 void pcap_close_file()
     84void pcap_close_file(void)
    8585{
    8686        pcap_writer.ops->close(&pcap_writer);
Note: See TracChangeset for help on using the changeset viewer.