Changeset 2ebbe9b in mainline
- Timestamp:
- 2024-12-13T08:32:55Z (10 months ago)
- Children:
- 9e26790
- Parents:
- 7924f82
- git-author:
- Nataliia Korop <n.corop08@…> (2024-03-20 17:06:29)
- git-committer:
- Nataliia Korop <n.corop08@…> (2024-12-13 08:32:55)
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/pcapctl/main.c
r7924f82 r2ebbe9b 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
r7924f82 r2ebbe9b 2201 2201 goto err_fun_bind; 2202 2202 2203 rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC); 2204 if (rc != EOK) 2205 goto err_add_to_cat; 2206 2207 rc = ddf_fun_add_to_category(fun, "pcap"); 2203 // rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC); 2204 // if (rc != EOK) 2205 // goto err_add_to_cat; 2206 2207 // rc = ddf_fun_add_to_category(fun, "pcap"); 2208 // if (rc != EOK) { 2209 // ddf_msg(LVL_ERROR, "Failed adding function to category pcap"); 2210 // goto err_add_to_cat; 2211 // } 2212 rc = nic_fun_add_to_cats(fun); 2208 2213 if (rc != EOK) { 2209 ddf_msg(LVL_ERROR, "Failed adding function to category pcap"); 2210 goto err_add_to_cat; 2211 } 2212 2214 ddf_msg(LVL_ERROR, "Failed adding function to categories"); 2215 return rc; 2216 } 2213 2217 return EOK; 2214 2218 2215 err_add_to_cat:2216 ddf_fun_unbind(fun);2219 // err_add_to_cat: 2220 // ddf_fun_unbind(fun); 2217 2221 err_fun_bind: 2218 2222 err_rx_structure: -
uspace/drv/nic/ne2k/ne2k.c
r7924f82 r2ebbe9b 455 455 return rc; 456 456 } 457 rc = ddf_fun_add_to_category(fun, "pcap"); 458 if (rc != EOK) { 459 //ddf_msg(LVL_ERROR, "Failed adding function to category pcap"); 460 ddf_fun_unbind(fun); 461 ddf_fun_destroy(fun); 462 return rc; 463 } 457 464 458 465 return EOK; -
uspace/drv/nic/rtl8139/driver.c
r7924f82 r2ebbe9b 42 42 #include <stdio.h> 43 43 #include <str.h> 44 #include <pcapdump_iface.h> 44 45 45 46 #include "defs.h" … … 1311 1312 } 1312 1313 1314 rc = ddf_fun_add_to_category(fun, "pcap"); 1315 if (rc != EOK) { 1316 ddf_msg(LVL_ERROR, "Failed adding function to category pcap"); 1317 goto err_fun_bind; 1318 } 1319 1313 1320 ddf_msg(LVL_NOTE, "The %s device has been successfully initialized.", 1314 1321 ddf_dev_get_name(dev)); -
uspace/lib/nic/include/nic.h
r7924f82 r2ebbe9b 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
r7924f82 r2ebbe9b 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
r7924f82 r2ebbe9b 55 55 extern errno_t pcapctl_list(void); 56 56 57 58 57 #endif 59 58 -
uspace/lib/pcap/src/pcapctl_dump.c
r7924f82 r2ebbe9b 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.