Changeset fb31682 in mainline for uspace/lib/pcap/src/pcap_dumper.c


Ignore:
Timestamp:
2024-12-13T08:44:05Z (10 months ago)
Author:
Nataliia Korop <n.corop08@…>
Children:
87b490e3
Parents:
28ed2d89
git-author:
Nataliia Korop <n.corop08@…> (2024-11-29 10:41:19)
git-committer:
Nataliia Korop <n.corop08@…> (2024-12-13 08:44:05)
Message:

user friendly options, trying to start while dumping → err msg

File:
1 edited

Legend:

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

    r28ed2d89 rfb31682  
    3939#include "pcap_dumper.h"
    4040
    41 #define SHORT_OPS_BYTE_COUNT 60
     41#define SHORT_OPS_BYTE_COUNT 0x3C
    4242
    4343/** Initialize writing to .pcap file.
     
    5050static errno_t pcap_writer_to_file_init(pcap_writer_t *writer, const char *filename)
    5151{
     52        /** For overwriting file if already exists. */
     53        writer->data = fopen(filename, "w");
     54        if (writer->data == NULL) {
     55                return EINVAL;
     56        }
     57        fclose(writer->data);
     58
    5259        writer->data = fopen(filename, "a");
    5360        if (writer->data == NULL) {
     
    7178static errno_t pcap_writer_to_file_usb_init(pcap_writer_t *writer, const char *filename)
    7279{
     80        /** For overwriting file if already exists. */
     81        writer->data = fopen(filename, "w");
     82        if (writer->data == NULL) {
     83                return EINVAL;
     84        }
     85        fclose(writer->data);
     86
    7387        writer->data = fopen(filename, "a");
    7488        if (writer->data == NULL) {
     
    140154};
    141155
    142 static pcap_writer_ops_t ops[4] = {file_ops, short_file_ops, append_file_ops, usb_file_ops};
     156static pcap_writer_ops_t ops[4] = { file_ops, short_file_ops, append_file_ops, usb_file_ops };
    143157
    144158int pcap_dumper_get_ops_number(void)
     
    150164{
    151165        fibril_mutex_lock(&dumper->mutex);
    152 
    153         /** When try to start when already started, close current and starts new */
    154         if (dumper->to_dump) {
    155                 pcap_dumper_stop(dumper);
    156         }
    157166
    158167        errno_t rc = dumper->writer.ops->open(&dumper->writer, name);
     
    201210}
    202211
    203 
    204 
    205212/** @}
    206213 */
Note: See TracChangeset for help on using the changeset viewer.