void selftest_client_xmit_packet(struct Adapter *adapter, struct Thread *thread, struct Packet *pkt) { struct TestAdapter *testadapter = (struct TestAdapter *)adapter->userdata; struct TestAdapter *other; struct Selftest *selftest = testadapter->parent; struct Frame frame[1]; if (&selftest->client == testadapter) other = &selftest->server; else other = &selftest->client; { struct PcapFile *x; x = pcapfile_openwrite("self-query.pcap", 1); pcapfile_writeframe(x, pkt->buf, pkt->max, pkt->max, 0, 0); pcapfile_close(x); } network_receive( frame, thread, other->adapter, 0, 0, pkt->buf, pkt->max); }
/**************************************************************************** * During a self-test, we intercept the client "transmit" function to * instead forward directly to the server "receive" path, thus simulating * from the server's point of a view the reception of a packet. We also * intercept the reverse path in the function * "selftest_server_to_client_response". ****************************************************************************/ void selftest_client_to_server_query(struct Adapter *adapter, struct Thread *thread, struct Packet *pkt) { struct TestAdapter *testadapter = (struct TestAdapter *)adapter->userdata; struct TestAdapter *other; struct Selftest *selftest = testadapter->parent; struct Frame frame[1]; if (&selftest->client == testadapter) other = &selftest->server; else other = &selftest->client; /* Save the query packet to a file for inspection */ { struct PcapFile *x; x = pcapfile_openwrite("self-query.pcap", 1); pcapfile_writeframe(x, pkt->buf, pkt->max, pkt->max, 0, 0); pcapfile_close(x); } /* * SHORT CIRCUIT * This is supposed to be a "transmit" function from the DNS client, * but what we are doing instead is just forwarding it to the * "receive" function of the DNS server. */ network_receive( frame, thread, other->adapter, 0, 0, pkt->buf, pkt->max); }