Changeset 87b490e3 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:
420b13d
Parents:
fb31682
git-author:
Nataliia Korop <n.corop08@…> (2024-11-30 19:08:32)
git-committer:
Nataliia Korop <n.corop08@…> (2024-12-13 08:44:05)
Message:

docs comments

File:
1 edited

Legend:

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

    rfb31682 r87b490e3  
    3030 * @{
    3131 */
    32 /** @file
    33  *  @brief pcap inteface: Dumping interface for the device which packets we want to dump
     32/** @file Pcap dumper. Structure is a part of every device that is in category PCAP and can dump packets.
    3433 */
    3534
     
    4342/** Initialize writing to .pcap file.
    4443 *
    45  * @param writer    Interface for working with .pcap file.
     44 * @param writer    Interface for writing data.
    4645 * @param filename  Name of the file for dumping packets.
    47  * @return          EOK on success or an error code.
     46 * @return          EOK on success, otherwise an error code.
    4847 *
    4948 */
     
    6665}
    6766
     67/** Open file for appending to the end of it.
     68 *  @param writer       Interface for writing data.
     69 *  @param filename Path to the file.
     70 *  @return             EOK on success, error code otherwise.
     71 */
    6872static errno_t pcap_writer_to_file_init_append(pcap_writer_t *writer, const char *filename)
    6973{
     
    7680}
    7781
     82/** Initialize file for dumping usb packets.
     83 *  @param writer       Interface for writing data.
     84 *  @param filename Path to the file.
     85 *  @return             EOK on success, error code otherwise.
     86 */
    7887static errno_t pcap_writer_to_file_usb_init(pcap_writer_t *writer, const char *filename)
    7988{
     
    94103}
    95104
     105/** Write 4B to the file.
     106 *  @param writer       Interface for writing data.
     107 *  @param data         Bytes to write.
     108 *  @return             Size of successfully witten data.
     109 */
    96110static size_t pcap_file_w32(pcap_writer_t *writer, uint32_t data)
    97111{
     
    99113}
    100114
     115/** Write 2B to the file.
     116 *  @param writer       Interface for writing data.
     117 *  @param data         Bytes to write.
     118 *  @return             Size of successfully witten data.
     119 */
    101120static size_t pcap_file_w16(pcap_writer_t *writer, uint16_t data)
    102121{
     
    104123}
    105124
     125/** Write block of bytes to the file.
     126 *  @param writer       Interface for writing data.
     127 *  @param data         Bytes to write.
     128 *  @param size         Size of block of bytes.
     129 *  @return             Size of successfully witten data.
     130 */
    106131static size_t pcap_file_wbuffer(pcap_writer_t *writer, const void *data, size_t size)
    107132{
     
    110135}
    111136
     137/** Close file for writing.
     138 *  @param writer       Interaface for writing data.
     139 */
    112140static void pcap_file_close(pcap_writer_t *writer)
    113141{
     
    116144}
    117145
     146/** Write <= 60B of block of bytes.
     147 *  @param writer       Interface for writing data.
     148 *  @param data         Bytes to write.
     149 *  @param size         Size of block of bytes.
     150 *  @return             Size of successfully witten data.
     151 */
    118152static size_t pcap_short_file_wbuffer(pcap_writer_t *writer, const void *data, size_t size)
    119153{
     
    121155}
    122156
     157/** Standard writer operations for writing data to a newly created file. */
    123158static const pcap_writer_ops_t file_ops = {
    124159        .open = &pcap_writer_to_file_init,
     
    129164};
    130165
     166/** Truncated writer operations. Only first 60 bytes of the packet are written. */
    131167static const pcap_writer_ops_t short_file_ops = {
    132168        .open = &pcap_writer_to_file_init,
     
    138174};
    139175
     176/** Append writer operations. Instead of creating new file open existing file and append packets. */
    140177static const pcap_writer_ops_t append_file_ops = {
    141178        .open = &pcap_writer_to_file_init_append,
     
    146183};
    147184
     185/** USB writer operations. Writing USB packets to the file. */
    148186static const pcap_writer_ops_t usb_file_ops = {
    149187        .open = &pcap_writer_to_file_usb_init,
     
    154192};
    155193
     194/** Default array of operations. Must be consistens with constants in /uspace/app/pcapctl/main.c */
    156195static pcap_writer_ops_t ops[4] = { file_ops, short_file_ops, append_file_ops, usb_file_ops };
    157196
     197/** Get number of writer operations in @ref ops */
    158198int pcap_dumper_get_ops_number(void)
    159199{
     
    161201}
    162202
     203/** Open destination buffer for writing and set flag for dumping.
     204 *  @param dumper       Structure responsible for dumping packets. Part of the driver.
     205 *  @param name         Name of the destination buffer to dump packets to.
     206 *  @return             EOK if successful, erro code otherwise.
     207 */
    163208errno_t pcap_dumper_start(pcap_dumper_t *dumper, const char *name)
    164209{
     
    174219}
    175220
     221/** Set writer options for the writer.
     222 *  @param dumper       Structure responsible for dumping packets. Part of the driver.
     223 *  @param index        Index of the writer operations from array @ref ops.
     224 *  @return             EOK if successful, erro code otherwise.
     225 */
    176226errno_t pcap_dumper_set_ops(pcap_dumper_t *dumper, int index)
    177227{
     
    183233}
    184234
     235/** Write packet to destination buffer.
     236 *  @param dumper       Structure responsible for dumping packets. Part of the driver.
     237 *  @param data         Packet data to write.
     238 *  @param size         Size of the packet.
     239 */
    185240void pcap_dumper_add_packet(pcap_dumper_t *dumper, const void *data, size_t size)
    186241{
     
    196251}
    197252
     253/** Close destination buffer for writing and unset flag for dumping.
     254 *  @param dumper       Structure responsible for dumping packets. Part of the driver.
     255 */
    198256void pcap_dumper_stop(pcap_dumper_t *dumper)
    199257{
Note: See TracChangeset for help on using the changeset viewer.