Changes in / [e846bec:325ea9c] in mainline


Ignore:
Location:
uspace
Files:
9 edited

Legend:

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

    re846bec r325ea9c  
    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     )
    4249
    4350pcapctl_sess_t sess;
  • uspace/drv/nic/e1k/e1k.c

    re846bec r325ea9c  
    4949#include <nic.h>
    5050#include <ops/nic.h>
    51 #include <pcapdump_iface.h>
    5251#include "e1k.h"
    5352
     53#include "pcapdump_iface.h"
     54#include "pcap_iface.h"
    5455#define NAME  "e1k"
    5556
     
    11911192                if (frame != NULL) {
    11921193                        memcpy(frame->data, e1000->rx_frame_virt[next_tail], frame_size);
     1194                        pcapdump_packet(nic_get_pcap_iface(nic), frame->data, frame->size);
    11931195
    11941196                        nic_received_frame(nic, frame);
     
    22062208                goto err_add_to_cat;
    22072209
     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        }
    22082215        rc = ddf_fun_add_to_category(fun, "pcap");
    2209         if (rc != EOK) {
    2210                 ddf_msg(LVL_ERROR, "Failed adding function to category pcap");
     2216        if (rc != EOK)
    22112217                goto err_add_to_cat;
    2212         }
    22132218
    22142219        return EOK;
     
    23752380
    23762381        memcpy(e1000->tx_frame_virt[tdt], data, size);
     2382        pcapdump_packet(nic_get_pcap_iface(nic), data, size);
    23772383        tx_descriptor_addr->phys_addr = PTR_TO_U64(e1000->tx_frame_phys[tdt]);
    23782384        tx_descriptor_addr->length = size;
  • uspace/drv/nic/virtio-net/virtio-net.c

    re846bec r325ea9c  
    4343
    4444#include <virtio-pci.h>
    45 #include <pcapdump_iface.h>
    46 
     45#include "pcapdump_iface.h"
     46#include "pcap_iface.h"
    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);
    9596                        nic_received_frame(nic, frame);
    9697                } else {
     
    352353        /* Copy packet data into the buffer just past the header */
    353354        memcpy(&hdr[1], data, size);
    354 
     355        pcapdump_packet(nic_get_pcap_iface(nic), data, size);
    355356        /*
    356357         * Set the descriptor, put it into the virtqueue and notify the device
     
    432433            ddf_dev_get_name(dev));
    433434
     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        }
    434440        rc = ddf_fun_add_to_category(fun, "pcap");
    435         if (rc != EOK) {
    436                 ddf_msg(LVL_ERROR, "Failed adding function to category pcap");
     441        if (rc != EOK)
    437442                goto unbind;
    438         }
    439443
    440444        return EOK;
  • uspace/lib/nic/include/nic.h

    re846bec r325ea9c  
    4444#include <device/hw_res_parsed.h>
    4545#include <ops/nic.h>
    46 #include <pcap_iface.h>
     46
     47#include "pcap_iface.h"
    4748
    4849#define DEVICE_CATEGORY_NIC "nic"
  • uspace/lib/nic/src/nic_driver.c

    re846bec r325ea9c  
    4747#include <ops/nic.h>
    4848#include <errno.h>
    49 #include <pcapdump_iface.h>
    5049
    5150#include "nic_driver.h"
     
    523522         *               calls it inside send_frame handler (with locked main lock)
    524523         */
    525         pcapdump_packet(nic_get_pcap_iface(nic_data), frame->data, frame->size);
    526524        fibril_rwlock_read_lock(&nic_data->rxc_lock);
    527525        nic_frame_type_t frame_type;
     
    562560                fibril_rwlock_write_unlock(&nic_data->stats_lock);
    563561        }
    564         //pcapdump_packet(nic_get_pcap_iface(nic_data), frame->data, frame->size);
    565562        nic_release_frame(nic_data, frame);
    566563}
     
    650647
    651648        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         }
    657649
    658650        return nic_data;
  • uspace/lib/nic/src/nic_impl.c

    re846bec r325ea9c  
    4040#include <ipc/services.h>
    4141#include <ns.h>
    42 #include <pcapdump_iface.h>
    4342#include "nic_driver.h"
    4443#include "nic_ev.h"
     
    180179                return EBUSY;
    181180        }
    182         pcapdump_packet(nic_get_pcap_iface(nic_data), data, size);
     181
    183182        nic_data->send_frame(nic_data, data, size);
    184183        fibril_rwlock_read_unlock(&nic_data->main_lock);
  • uspace/lib/pcap/include/pcap.h

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

    re846bec r325ea9c  
    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     )
    3744
    3845#include "pcap.h"
     
    101108        if (writer->data == NULL) {
    102109                rc = EINVAL;
     110                LOGGER("Failed to create %s: %s.", filename, str_error(rc));
    103111                return rc;
    104112        }
  • uspace/lib/pcap/src/pcap_iface.c

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