net/socket.c
SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)->sock_create()->__sock_create()->
pf = rcu_dereference(net_families[family]);
err = pf->create(net, sock, protocol, kern);
bt_init()->
err = sock_register(&bt_sock_family_ops);
static struct net_proto_family bt_sock_family_ops = {
.owner = THIS_MODULE,
.family = PF_BLUETOOTH,
.create = bt_sock_create,
};
bt_sock_create()->
err = bt_proto[proto]->create(net, sock, proto, kern);
bt_proto[proto]注册如下:
bt_init()->hci_sock_init()->bt_sock_register(BTPROTO_HCI, &hci_sock_family_ops)->
bt_proto[proto] = ops;
static const struct net_proto_family hci_sock_family_ops = {
.family = PF_BLUETOOTH,
.owner = THIS_MODULE,
.create = hci_sock_create,
};
hci_sock_create()->sock->ops = &hci_sock_ops
net/bluetooth/hci_sock.c
static const struct proto_ops hci_sock_ops = {
.family = PF_BLUETOOTH,
.owner = THIS_MODULE,
.release = hci_sock_release,
.bind = hci_sock_bind,
.getname = hci_sock_getname,
.sendmsg = hci_sock_sendmsg,
.recvmsg