Changeset 87b490e3 in mainline for uspace/app/pcapctl/main.c
- Timestamp:
- 2024-12-13T08:44:05Z (10 months ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/pcapctl/main.c
rfb31682 r87b490e3 30 30 * @{ 31 31 */ 32 /** @file pcapctl app32 /** @file pcapctl command-line utility. 33 33 */ 34 34 … … 42 42 #include "pcapdump_client.h" 43 43 44 #define NAME "pcapctl" 45 #define DEFAULT_DEV_NUM 0 46 #define DECIMAL_SYSTEM 10 47 48 #define DEFAULT_FILE_OPS 0 49 #define SHORT_FILE_OPS 1 50 #define APPEND_FILE_OPS 2 51 #define USB_FILE_OPS 3 52 44 #define NAME "pcapctl" 45 #define DEFAULT_DEV_NUM 0 46 #define DECIMAL_SYSTEM 10 47 48 /* Default writer operations for dumper, must be consistent with array defined in /uspace/lib/pcap/pcap_dumper.c */ 49 #define DEFAULT_FILE_OPS 0 50 #define SHORT_FILE_OPS 1 51 #define APPEND_FILE_OPS 2 52 #define USB_FILE_OPS 3 53 54 /** Create async session and send start request. 55 * @param dev_number index of the device that can dump packets. 56 * @param name of the output buffer. 57 * @param ops_index index of the writer operations for the dumper. 58 * @return EOK if all parameters are valid and start request was sent successfully, error code otherwise. 59 */ 53 60 static errno_t start_dumping(int *dev_number, const char *name, int *ops_index) 54 61 { … … 77 84 } 78 85 86 /** Create async session and send stop dumping request. 87 * @param dev_numbe index of the device on which the dumping will be stopped. 88 * @return EOK if request was sent successfully, error code otherwise. 89 */ 79 90 static errno_t stop_dumping(int *dev_number) 80 91 { … … 92 103 } 93 104 105 /** Print devices that can dump packets. */ 94 106 static void list_devs(void) 95 107 { … … 101 113 */ 102 114 static const struct option opts[] = { 103 { "append", required_argument, 0, 'A' }, / / file as argument and ops 0 if not exist and 2 if exists104 { "new", required_argument, 0, 'N' }, / / file name as argument115 { "append", required_argument, 0, 'A' }, /* file as argument and ops 0 if not exist and 2 if exists */ 116 { "new", required_argument, 0, 'N' }, /* file name as argument */ 105 117 { "truncated", required_argument, 0, 'T' }, // truncated ops 106 118 { "usb", required_argument, 0, 'U' }, //?? … … 116 128 }; 117 129 130 /** Check if the file exists. 131 * @param path of the file to check. 132 * @return true if exists, false otherwise. 133 */ 118 134 static bool file_exists(const char *path) 119 135 { … … 128 144 static void usage(void) 129 145 { 130 printf("Usage:\n" 146 printf("HelenOS Packet Dumping utility.\n" 147 "Usage:\n" 131 148 NAME " --list | -l \n" 132 149 "\tList of devices\n" … … 218 235 } 219 236 220 printf("%s: HelenOS Packet Dumping utility: device - %d, ops - %d.\n", NAME, dev_number, ops_number);221 222 237 if (start) { 223 238 … … 227 242 } 228 243 244 printf("Sarting dumping on device - %d, ops - %d.\n", dev_number, ops_number); 245 229 246 /* start with dev number and name */ 230 247 start_dumping(&dev_number, output_file_name, &ops_number); 231 248 } else if (stop) { 232 249 /* stop with dev number */ 250 printf("Stopping dumping on device - %d, ops - %d.\n", dev_number, ops_number); 233 251 stop_dumping(&dev_number); 234 252 } else {
Note:
See TracChangeset
for help on using the changeset viewer.