DF-5752 / hci_stub.c
/* * hci_stub.c -- minimal socket/signal stubs for the hci_unit_harness KLD. * * The production netbt code (sys/netbt/hci_unit.c, bt_input.c, hci_event.c, * hci_link.c, hci_misc.c, l2cap_lower.c, sco_upper.c) is compiled VERBATIM * into this module. Everything those files need from the layers we do not * compile (hci_socket.c, bt_proto.c, l2cap_misc.c, l2cap_signal.c, * l2cap_upper.c, l2cap_socket.c, sco_socket.c) is stubbed here: * * - M_BLUETOOTH malloc type (lives in bt_proto.c normally) * - l2cap_pdu_pool / l2cap_req_pool vm_zones (bt_proto.c netbt_init) * - l2cap_active_list (l2cap_misc.c) * - l2cap_recv_signal / l2cap_cid_lookup / l2cap_send_disconnect_req / * l2cap_send_connect_req / l2cap_send_config_req / l2cap_request_free * (l2cap_signal.c / l2cap_misc.c) * - hci_mtap / hci_drop (hci_socket.c) -- no raw HCI sockets in the rig * * NOTE: l2cap_close(), l2cap_start(), l2cap_recv_frame() come VERBATIM * from the compiled l2cap_lower.c -- that is code under test. */ #include <sys/param.h> #include <sys/kernel.h> #include <sys/malloc.h> #include <sys/mbuf.h> #include <sys/systm.h> #include <sys/types.h> #include <net/if.h> #include <netbt/bluetooth.h> #include <netbt/hci.h> #include <netbt/l2cap.h> #include <netbt/sco.h> /* real malloc type lives in bt_proto.c which we do not compile in */ MALLOC_DEFINE(M_BLUETOOTH, "Bluetooth", "Bluetooth system memory"); /* zones normally created by netbt_init() in bt_proto.c */ vm_zone_t l2cap_pdu_pool; vm_zone_t l2cap_req_pool; /* channel list normally in l2cap_misc.c */ struct l2cap_channel_list l2cap_active_list = LIST_HEAD_INITIALIZER(l2cap_active_list); /* NOTE: hci_mtap()/hci_drop() are implemented in harness.c (the DF-5752 * tracking hook): hci_intr() calls hci_mtap() for every packet it * dequeues, which is where the rig observes the freed-mbuf/netmsg * lifetime. */ void l2cap_recv_signal(struct mbuf *m, struct hci_link *link) { m_freem(m); } struct l2cap_channel * l2cap_cid_lookup(uint16_t cid) { return NULL; } int l2cap_send_disconnect_req(struct l2cap_channel *chan) { return 0; } void l2cap_request_free(struct l2cap_req *req) { kfree(req, M_BLUETOOTH); } int l2cap_send_connect_req(struct l2cap_channel *chan) { return 0; } int l2cap_send_config_req(struct l2cap_channel *chan) { return 0; } int l2cap_send_connect_rsp(struct hci_link *link, uint8_t ident, uint16_t dcid, uint16_t scid, uint16_t result) { return 0; } |