Changeset 6c60a7c in mainline
- Timestamp:
- 2024-12-13T08:33:34Z (10 months ago)
- Children:
- c7bd3f9e
- Parents:
- 1a59a89
- git-author:
- Nataliia Korop <n.corop08@…> (2024-04-11 09:36:03)
- git-committer:
- Nataliia Korop <n.corop08@…> (2024-12-13 08:33:34)
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/nic/src/nic_driver.c
r1a59a89 r6c60a7c 523 523 * calls it inside send_frame handler (with locked main lock) 524 524 */ 525 pcapdump_packet(nic_get_pcap_iface(nic_data), frame->data, frame->size);525 //pcapdump_packet(nic_get_pcap_iface(nic_data), frame->data, frame->size); 526 526 fibril_rwlock_read_lock(&nic_data->rxc_lock); 527 527 nic_frame_type_t frame_type; … … 651 651 nic_data->dev = device; 652 652 653 errno_t pcap_rc = pcapdump_init(nic_get_pcap_iface(nic_data));654 if (pcap_rc != EOK) {655 printf("Failed creating pcapdump port\n");656 }653 // errno_t pcap_rc = pcapdump_init(nic_get_pcap_iface(nic_data)); 654 // if (pcap_rc != EOK) { 655 // printf("Failed creating pcapdump port\n"); 656 // } 657 657 658 658 return nic_data; -
uspace/lib/nic/src/nic_impl.c
r1a59a89 r6c60a7c 180 180 return EBUSY; 181 181 } 182 pcapdump_packet(nic_get_pcap_iface(nic_data), data, size);182 //pcapdump_packet(nic_get_pcap_iface(nic_data), data, size); 183 183 nic_data->send_frame(nic_data, data, size); 184 184 fibril_rwlock_read_unlock(&nic_data->main_lock); … … 849 849 rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC); 850 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; 851 return rc; 852 853 // rc = ddf_fun_add_to_category(fun, "pcap"); 854 // if (rc != EOK) { 855 // return rc; 856 // } 857 return EOK; 863 858 } 864 859 -
uspace/lib/pcap/include/pcapdump_iface.h
r1a59a89 r6c60a7c 51 51 extern void pcapdump_packet(pcap_iface_t *, const void *, size_t); 52 52 53 extern void pcapdump_conn(ipc_call_t *, void *); 53 54 #endif 54 55 -
uspace/lib/pcap/src/pcapctl_dump.c
r1a59a89 r6c60a7c 52 52 } 53 53 54 static errno_t pcapctl_cat_get_svc(int *index, service_id_t *svc)55 {56 errno_t rc;57 category_id_t pcap_cat;58 size_t count;59 service_id_t *pcap_svcs = NULL;60 61 rc = loc_category_get_id("pcap", &pcap_cat, 0);62 if (rc != EOK) {63 printf("Error resolving category 'pcap'.\n");64 return rc;65 }66 67 rc = loc_category_get_svcs(pcap_cat, &pcap_svcs, &count);68 if (rc != EOK) {69 printf("Error resolving list of pcap services.\n");70 free(pcap_svcs);71 return rc;72 }73 if (*index < (int)count) {74 *svc = pcap_svcs[*index];75 free(pcap_svcs);76 return EOK;77 }78 79 return ENOENT;80 }54 // static errno_t pcapctl_cat_get_svc(int *index, service_id_t *svc) 55 // { 56 // errno_t rc; 57 // category_id_t pcap_cat; 58 // size_t count; 59 // service_id_t *pcap_svcs = NULL; 60 61 // rc = loc_category_get_id("pcap", &pcap_cat, 0); 62 // if (rc != EOK) { 63 // printf("Error resolving category 'pcap'.\n"); 64 // return rc; 65 // } 66 67 // rc = loc_category_get_svcs(pcap_cat, &pcap_svcs, &count); 68 // if (rc != EOK) { 69 // printf("Error resolving list of pcap services.\n"); 70 // free(pcap_svcs); 71 // return rc; 72 // } 73 // if (*index < (int)count) { 74 // *svc = pcap_svcs[*index]; 75 // free(pcap_svcs); 76 // return EOK; 77 // } 78 79 // return ENOENT; 80 // } 81 81 82 82 errno_t pcapctl_is_valid_device(int *index) … … 149 149 return ENOMEM; 150 150 151 rc = pcapctl_cat_get_svc(index, &svc); 152 if (rc != EOK) { 153 printf("Error finding the device with index: %d\n", *index); 154 goto error; 155 } 151 // rc = pcapctl_cat_get_svc(index, &svc); 152 // if (rc != EOK) { 153 // printf("Error finding the device with index: %d\n", *index); 154 // goto error; 155 // } 156 157 rc = loc_service_get_id("net/inet", &svc, 0); 158 if (rc != EOK) 159 return ENOENT; 156 160 157 161 async_sess_t *new_session = loc_service_connect(svc, INTERFACE_PCAP_CONTROL, 0); … … 161 165 goto error; 162 166 } 167 printf("got new session\n"); 163 168 sess->sess = new_session; 164 169 *rsess = sess; … … 186 191 errno_t pcapctl_dump_start(const char *name, pcapctl_sess_t *sess) 187 192 { 193 printf("pcapctl_dump_start\n"); 188 194 errno_t rc; 189 195 async_exch_t *exch = async_exchange_begin(sess->sess); -
uspace/lib/pcap/src/pcapdump_iface.c
r1a59a89 r6c60a7c 83 83 } 84 84 85 staticvoid pcapdump_conn(ipc_call_t *icall, void *arg)85 void pcapdump_conn(ipc_call_t *icall, void *arg) 86 86 { 87 87 pcap_iface_t *iface = (pcap_iface_t *)arg; 88 88 printf("pcapdump_conn\n"); 89 89 assert((iface != NULL) && "pcapdump requires pcap interface\n"); 90 90 -
uspace/srv/net/inetsrv/inetsrv.c
r1a59a89 r6c60a7c 49 49 #include <stdint.h> 50 50 #include <task.h> 51 #include <pcapdump_iface.h> 51 52 #include "addrobj.h" 52 53 #include "icmp.h" … … 63 64 #define NAME "inetsrv" 64 65 66 /** Interface for dumping packets */ 67 pcap_iface_t pcapdump; 68 65 69 static inet_naddr_t solicited_node_mask = { 66 70 .version = ip_v6, … … 117 121 if (rc != EOK) 118 122 return rc; 119 123 rc = async_create_port(INTERFACE_PCAP_CONTROL, 124 pcapdump_conn, &pcapdump, &port); 125 if (rc != EOK) { 126 return rc; 127 } 120 128 rc = loc_server_register(NAME, &srv); 121 129 if (rc != EOK) { … … 202 210 dgram->dest.addr, dgram, proto, ttl, df); 203 211 } 204 212 printf("SENDING: packet size is - %d\n", dgram->size); 213 pcapdump_packet(&pcapdump, dgram->data, dgram->size); 205 214 log_msg(LOG_DEFAULT, LVL_DEBUG, "dgram to be routed"); 206 215 … … 541 550 dgram.data = packet->data; 542 551 dgram.size = packet->size; 543 552 printf("RECEIVING: packet size is - %d\n", packet->size); 553 pcapdump_packet(&pcapdump, packet->data, packet->size); 544 554 return inet_recv_dgram_local(&dgram, packet->proto); 545 555 } else { … … 562 572 return 1; 563 573 } 564 574 rc = pcap_iface_init(&pcapdump); 575 576 if (rc != EOK) { 577 printf("Failed creating pcap interface: %s", str_error(rc)); 578 return rc; 579 } 565 580 rc = inet_init(); 566 581 if (rc != EOK) 567 582 return 1; 568 583 584 printf(NAME ": Initialized dump iface from inetsrv.\n"); 569 585 printf(NAME ": Accepting connections.\n"); 570 586 -
uspace/srv/net/inetsrv/meson.build
r1a59a89 r6c60a7c 27 27 # 28 28 29 deps = [ 'inet', 'sif' ] 29 deps = [ 'inet', 'sif', 'pcap' ] 30 30 31 src = files( 31 32 'addrobj.c',
Note:
See TracChangeset
for help on using the changeset viewer.