Changeset 8d9217d in mainline
- Timestamp:
- 2024-03-20T17:06:29Z (9 months ago)
- Children:
- 384f081
- Parents:
- 78edb5e
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/pcapctl/main.c
r78edb5e r8d9217d 40 40 41 41 #define NAME "pcapctl" 42 #define DEFAULT_DEV_NUM 0 42 43 43 44 //pcapctl_sess_t* sess = NULL; … … 45 46 static errno_t start_dumping(const char *svc_name, const char *name) 46 47 { 47 pcapctl_sess_t *sess = NULL;48 pcapctl_sess_t *sess = NULL; 48 49 errno_t rc = pcapctl_dump_open(svc_name, &sess); 49 50 if (rc != EOK) { … … 59 60 static errno_t stop_dumping(const char *svc_name) 60 61 { 61 pcapctl_sess_t *sess = NULL;62 pcapctl_sess_t *sess = NULL; 62 63 errno_t rc = pcapctl_dump_open(svc_name, &sess); 63 64 if (rc != EOK) { … … 69 70 } 70 71 71 static void list_devs(void) { 72 static void list_devs(void) 73 { 72 74 pcapctl_list(); 73 75 } … … 76 78 { 77 79 printf("Usage:\n" 78 79 80 81 82 83 84 85 86 87 80 NAME " list \n" 81 "\tList of devices\n" 82 NAME " start --device= | -d <device number from list> <outfile>\n" 83 "\tPackets dumped from device will be written to <outfile>\n" 84 NAME " stop --device= | -d <device>\n" 85 "\tDumping from <device> stops\n" 86 NAME " start <outfile>\n" 87 "\tPackets dumped from the 1st device from the list will be written to <outfile>\n" 88 NAME " --help | -h\n" 89 "\tShow this application help.\n"); 88 90 } 89 91 … … 94 96 return 1; 95 97 } else { 96 /** help */98 /** help */ 97 99 if (str_cmp(argv[1], "--help") == 0 || str_cmp(argv[1], "-h") == 0) { 98 100 usage(); 99 101 return 0; 100 /** list*/102 /** list */ 101 103 } else if (str_cmp(argv[1], "list") == 0) { 102 104 list_devs(); 103 105 return 0; 104 /** start with/out devnum */106 /** start with/out devnum */ 105 107 } else if (str_cmp(argv[1], "start") == 0) { 106 108 if (argc == 3) { 107 109 start_dumping((char *)"0", argv[2]); 108 110 return 0; 109 } 110 else if (argc == 4) { 111 } else if (argc == 4) { 111 112 start_dumping(argv[2], argv[3]); 112 113 return 0; … … 115 116 return 1; 116 117 } 117 /** Stop with/out devnum */118 /** Stop with/out devnum */ 118 119 } else if (str_cmp(argv[1], "stop") == 0) { 119 120 if (argc == 2) { … … 121 122 fprintf(stdout, "Dumping was stopped\n"); 122 123 return 0; 123 } 124 else if (argc == 3) { 124 } else if (argc == 3) { 125 125 126 126 stop_dumping(argv[2]); -
uspace/drv/nic/e1k/e1k.c
r78edb5e r8d9217d 2202 2202 goto err_fun_bind; 2203 2203 2204 rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC); 2205 if (rc != EOK) 2206 goto err_add_to_cat; 2207 2208 rc = ddf_fun_add_to_category(fun, "pcap"); 2204 // rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC); 2205 // if (rc != EOK) 2206 // goto err_add_to_cat; 2207 2208 // rc = ddf_fun_add_to_category(fun, "pcap"); 2209 // if (rc != EOK) { 2210 // ddf_msg(LVL_ERROR, "Failed adding function to category pcap"); 2211 // goto err_add_to_cat; 2212 // } 2213 rc = nic_fun_add_to_cats(fun); 2209 2214 if (rc != EOK) { 2210 ddf_msg(LVL_ERROR, "Failed adding function to category pcap"); 2211 goto err_add_to_cat; 2212 } 2213 2215 ddf_msg(LVL_ERROR, "Failed adding function to categories"); 2216 return rc; 2217 } 2214 2218 return EOK; 2215 2219 2216 err_add_to_cat:2217 ddf_fun_unbind(fun);2220 // err_add_to_cat: 2221 // ddf_fun_unbind(fun); 2218 2222 err_fun_bind: 2219 2223 err_rx_structure: -
uspace/drv/nic/ne2k/ne2k.c
r78edb5e r8d9217d 449 449 return rc; 450 450 } 451 rc = ddf_fun_add_to_category(fun, "pcap"); 452 if (rc != EOK) { 453 //ddf_msg(LVL_ERROR, "Failed adding function to category pcap"); 454 ddf_fun_unbind(fun); 455 ddf_fun_destroy(fun); 456 return rc; 457 } 451 458 452 459 return EOK; -
uspace/drv/nic/rtl8139/driver.c
r78edb5e r8d9217d 42 42 #include <stdio.h> 43 43 #include <str.h> 44 #include <pcapdump_iface.h> 44 45 45 46 #include "defs.h" … … 1313 1314 } 1314 1315 1316 rc = ddf_fun_add_to_category(fun, "pcap"); 1317 if (rc != EOK) { 1318 ddf_msg(LVL_ERROR, "Failed adding function to category pcap"); 1319 goto err_fun_bind; 1320 } 1321 1315 1322 ddf_msg(LVL_NOTE, "The %s device has been successfully initialized.", 1316 1323 ddf_dev_get_name(dev)); -
uspace/lib/nic/include/nic.h
r78edb5e r8d9217d 282 282 extern pcap_iface_t *nic_get_pcap_iface(nic_t *); 283 283 284 extern errno_t nic_fun_add_to_cats(ddf_fun_t *fun); 285 284 286 #endif // __NIC_H__ 285 287 -
uspace/lib/nic/src/nic_impl.c
r78edb5e r8d9217d 844 844 } 845 845 846 errno_t nic_fun_add_to_cats(ddf_fun_t *fun) 847 { 848 errno_t rc; 849 rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC); 850 if (rc != EOK) 851 goto err_add_to_cat; 852 853 rc = ddf_fun_add_to_category(fun, "pcap"); 854 if (rc != EOK) { 855 //ddf_msg(LVL_ERROR, "Failed adding function to category pcap"); 856 goto err_add_to_cat; 857 } 858 return EOK; 859 860 err_add_to_cat: 861 ddf_fun_unbind(fun); 862 return rc; 863 } 864 846 865 /** @} 847 866 */ -
uspace/lib/pcap/include/pcapctl_dump.h
r78edb5e r8d9217d 55 55 extern errno_t pcapctl_list(void); 56 56 57 58 57 #endif 59 58 -
uspace/lib/pcap/src/pcapctl_dump.c
r78edb5e r8d9217d 45 45 //static service_id_t *pcap_svcs = NULL; ?? 46 46 47 static errno_t str2num(const char* str, size_t* number) { 47 static errno_t str2num(const char *str, size_t *number) 48 { 48 49 size_t num = 0; 49 50 if (*str == 0) … … 68 69 } 69 70 70 static errno_t pcapctl_cat_get_svc(const char *drv_name, service_id_t* svc) { 71 static errno_t pcapctl_cat_get_svc(const char *drv_name, service_id_t *svc) 72 { 71 73 errno_t rc; 72 74 category_id_t pcap_cat; … … 98 100 } 99 101 100 e xtern errno_t pcapctl_list(void) {101 102 errno_t pcapctl_list(void) 103 { 102 104 errno_t rc; 103 105 category_id_t pcap_cat; … … 118 120 } 119 121 120 fprintf(stdout, " Services:\n");122 fprintf(stdout, "Devices:\n"); 121 123 for (unsigned i = 0; i < count; ++i) { 122 124 char *name = NULL; … … 128 130 } 129 131 130 131 static errno_t pcapctl_get_name_from_number(const char* svcnum, const char** svcname) { 132 132 static errno_t pcapctl_get_name_from_number(const char *svcnum, const char **svcname) 133 { 133 134 errno_t rc; 134 135 category_id_t pcap_cat; … … 183 184 return ENOMEM; 184 185 185 186 const char* svcname; 186 const char *svcname; 187 187 188 188 rc = pcapctl_get_name_from_number(svcnum, &svcname);
Note:
See TracChangeset
for help on using the changeset viewer.