Changeset 467d2b9 in mainline
- Timestamp:
- 2024-12-13T08:44:05Z (11 months ago)
- Children:
- e1e8f7a
- Parents:
- f161ce1
- git-author:
- Nataliia Korop <n.corop08@…> (2024-11-10 18:34:17)
- git-committer:
- Nataliia Korop <n.corop08@…> (2024-12-13 08:44:05)
- Location:
- uspace/lib/pcap
- Files:
-
- 4 edited
-
include/pcap.h (modified) (5 diffs)
-
src/pcap.c (modified) (1 diff)
-
src/pcap_dumper.c (modified) (3 diffs)
-
src/pcapdump_srv.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/pcap/include/pcap.h
rf161ce1 r467d2b9 58 58 #define WIRESHARK_SNAPLEN 0xffff 59 59 60 /** Header of the .pcap file 61 */ 60 /** Header of the .pcap file. */ 62 61 typedef struct { 63 62 uint32_t magic_number; … … 70 69 } pcap_file_header_t; 71 70 71 /** Header of the packet to be dumped to .pcap file. */ 72 72 typedef struct pcap_packet_header { 73 73 uint32_t seconds_stamp; … … 79 79 typedef struct pcap_writer pcap_writer_t; 80 80 81 /** Operations for dumper. */ 81 82 typedef struct { 82 83 errno_t (*open)(struct pcap_writer *, const char *); … … 85 86 size_t (*write_buffer)(struct pcap_writer *, const void *, size_t); 86 87 void (*close)(struct pcap_writer *); 87 88 88 } pcap_writer_ops_t; 89 89 90 /** Interface for working with .pcap file 91 */ 90 /** Interface for working with .pcap file. */ 92 91 typedef struct pcap_writer { 93 92 void *data; … … 95 94 } pcap_writer_t; 96 95 97 extern void pcap_writer_add_header(pcap_writer_t * );96 extern void pcap_writer_add_header(pcap_writer_t *writer); 98 97 extern void pcap_writer_add_packet(pcap_writer_t *writer, const void *captured_packet, size_t size); 99 98 extern void pcap_set_time(pcap_packet_header_t *header); -
uspace/lib/pcap/src/pcap.c
rf161ce1 r467d2b9 53 53 /** Add pcap file header to the new .pcap file. 54 54 * 55 * @param writer 55 * @param writer writer that has destination buffer and ops to write to destination buffer. 56 56 * 57 57 */ -
uspace/lib/pcap/src/pcap_dumper.c
rf161ce1 r467d2b9 36 36 #include <errno.h> 37 37 #include <str.h> 38 #include <io/log.h> 38 39 #include "pcap_dumper.h" 39 40 40 41 /** Initialize writing to .pcap file. 41 42 * 42 * @param writer Interface for working with .pcap file 43 * @param filename Name of the file for dumping packets 44 * @return EOK on success or an error code 43 * @param writer Interface for working with .pcap file. 44 * @param filename Name of the file for dumping packets. 45 * @return EOK on success or an error code. 45 46 * 46 47 */ … … 126 127 pcap_dumper_stop(dumper); 127 128 } 129 128 130 errno_t rc = dumper->writer.ops->open(&dumper->writer, name); 129 131 if (rc == EOK) { 130 132 dumper->to_dump = true; 131 } else { 132 printf("Failed creating pcap dumper: %s", str_error(rc)); 133 } 133 } 134 134 135 fibril_mutex_unlock(&dumper->mutex); 135 136 return rc; … … 188 189 dumper->to_dump = false; 189 190 dumper->writer.ops = NULL; 191 192 errno_t rc = log_init("pcap"); 193 if (rc != EOK) { 194 printf("pcap : Failed to initialize log.\n"); 195 return 1; 196 } 190 197 return EOK; 191 198 } -
uspace/lib/pcap/src/pcapdump_srv.c
rf161ce1 r467d2b9 41 41 #include <fibril_synch.h> 42 42 #include <str.h> 43 #include <io/log.h> 43 44 44 45 #include "pcapdump_srv.h" … … 59 60 free(data); 60 61 if (rc != EOK) { 61 //TODO what?62 log_msg(LOG_DEFAULT, LVL_DEBUG, "Starting the dumping was not successful.\n"); 62 63 } 63 64 async_answer_0(icall, EOK); … … 85 86 free(data); 86 87 if (rc != EOK) { 87 //TODO what?88 log_msg(LOG_DEFAULT, LVL_DEBUG, "Setting ops for dumper was not successful.\n"); 88 89 } 90 91 log_msg(LOG_DEFAULT, LVL_NOTE, "Setting ops for dumper was successful.\n"); 92 89 93 async_answer_0(icall, EOK); 90 91 94 } 92 95 … … 134 137 135 138 if (rc != EOK) { 136 printf("Failed creating pcap interface: %s", str_error(rc));139 log_msg(LOG_DEFAULT, LVL_DEBUG, "Failed creating pcap interface: %s", str_error(rc)); 137 140 return rc; 138 141 } 139 142 140 rc = async_create_port(INTERFACE_PCAP_CONTROL, 141 pcapdump_conn, dumper, &port); 143 rc = async_create_port(INTERFACE_PCAP_CONTROL, pcapdump_conn, dumper, &port); 142 144 if (rc != EOK) { 145 log_msg(LOG_DEFAULT, LVL_DEBUG, "Failed creating port: %s", str_error(rc)); 143 146 return rc; 144 147 }
Note:
See TracChangeset
for help on using the changeset viewer.
