Lines Matching defs:kctl
78 TAILQ_HEAD(kctl_list, kctl) ctl_head;
92 static struct kctl *ctl_find_by_name(const char *);
93 static struct kctl *ctl_find_by_id_unit(u_int32_t id, u_int32_t unit);
95 static struct ctl_cb *kcb_find(struct kctl *, u_int32_t unit);
255 struct kctl *kctl;
256 if ((kctl = kcb->kctl) != 0) {
258 TAILQ_REMOVE(&kctl->kcb_head, kcb, next);
284 struct kctl *kctl;
299 kctl = ctl_find_by_id_unit(sa.sc_id, sa.sc_unit);
300 if (kctl == NULL) {
305 if (((kctl->flags & CTL_FLAG_REG_SOCK_STREAM) && (so->so_type != SOCK_STREAM)) ||
306 (!(kctl->flags & CTL_FLAG_REG_SOCK_STREAM) && (so->so_type != SOCK_DGRAM))) {
311 if (kctl->flags & CTL_FLAG_PRIVILEGED) {
322 if ((kctl->flags & CTL_FLAG_REG_ID_UNIT) || sa.sc_unit != 0) {
323 if (kcb_find(kctl, sa.sc_unit) != NULL) {
331 TAILQ_FOREACH(kcb_next, &kctl->kcb_head, next) {
350 kcb->kctl = kctl;
355 TAILQ_INSERT_TAIL(&kctl->kcb_head, kcb, next);
359 error = soreserve(so, kctl->sendbufsize, kctl->recvbufsize);
365 error = (*kctl->connect)(kctl, &sa, &kcb->userdata);
376 kcb->kctl = 0;
378 TAILQ_REMOVE(&kctl->kcb_head, kcb, next);
390 struct kctl *kctl = kcb->kctl;
392 if (kctl && kctl->disconnect) {
394 (*kctl->disconnect)(kctl, kcb->unit, kcb->userdata);
398 kcb->kctl = 0;
400 TAILQ_REMOVE(&kctl->kcb_head, kcb, next);
411 struct kctl *kctl;
417 if ((kctl = kcb->kctl) == NULL)
424 sc.sc_id = kctl->id;
439 struct kctl *kctl;
444 if ((kctl = kcb->kctl) == NULL)
447 if (kctl->send) {
449 error = (*kctl->send)(kctl, kcb->unit, kcb->userdata, m, flags);
461 struct kctl *kctl = (struct kctl *)kctlref;
463 if (kctl == NULL)
466 kcb = kcb_find(kctl, unit);
495 struct kctl *kctl = (struct kctl *)kctlref;
503 kcb = kcb_find(kctl, unit);
550 struct kctl *kctl = (struct kctl *)kctlref;
557 kcb = kcb_find(kctl, unit);
577 struct kctl *kctl;
589 if ((kctl = kcb->kctl) == NULL)
594 if (kctl->setopt == NULL)
606 error = (*kctl->setopt)(kcb->kctl, kcb->unit, kcb->userdata, sopt->sopt_name,
614 if (kctl->getopt == NULL)
626 error = (*kctl->getopt)(kcb->kctl, kcb->unit, kcb->userdata, sopt->sopt_name,
651 struct kctl *kctl;
655 TAILQ_FOREACH(kctl, &ctl_head, next)
665 struct kctl *kctl = 0;
673 kctl = ctl_find_by_name(ctl_info->ctl_name);
675 if (kctl == 0) {
679 ctl_info->ctl_id = kctl->id;
697 struct kctl *kctl = NULL;
698 struct kctl *kctl_next = NULL;
710 MALLOC(kctl, struct kctl *, sizeof(*kctl), M_TEMP, M_WAITOK);
711 if (kctl == NULL)
713 bzero((char *)kctl, sizeof(*kctl));
734 FREE(kctl, M_TEMP);
767 kctl->id = id;
768 kctl->reg_unit = -1;
777 FREE(kctl, M_TEMP);
780 kctl->id = userkctl->ctl_id;
781 kctl->reg_unit = userkctl->ctl_unit;
783 strlcpy(kctl->name, userkctl->ctl_name, MAX_KCTL_NAME);
784 kctl->flags = userkctl->ctl_flags;
789 kctl->sendbufsize = userkctl->ctl_sendsize;
793 kctl->recvbufsize = userkctl->ctl_recvsize;
795 kctl->connect = userkctl->ctl_connect;
796 kctl->disconnect = userkctl->ctl_disconnect;
797 kctl->send = userkctl->ctl_send;
798 kctl->setopt = userkctl->ctl_setopt;
799 kctl->getopt = userkctl->ctl_getopt;
801 TAILQ_INIT(&kctl->kcb_head);
804 TAILQ_INSERT_BEFORE(kctl_next, kctl, next);
806 TAILQ_INSERT_TAIL(&ctl_head, kctl, next);
810 *kctlref = kctl;
812 ctl_post_msg(KEV_CTL_REGISTERED, kctl->id);
819 struct kctl *kctl;
825 TAILQ_FOREACH(kctl, &ctl_head, next) {
826 if (kctl == (struct kctl *)kctlref)
829 if (kctl != (struct kctl *)kctlref) {
833 if (!TAILQ_EMPTY(&kctl->kcb_head)) {
838 TAILQ_REMOVE(&ctl_head, kctl, next);
842 ctl_post_msg(KEV_CTL_DEREGISTERED, kctl->id);
843 FREE(kctl, M_TEMP);
850 static struct kctl *
853 struct kctl *kctl;
855 TAILQ_FOREACH(kctl, &ctl_head, next)
856 if (strncmp(kctl->name, name, sizeof(kctl->name)) == 0)
857 return kctl;
866 static struct kctl *
869 struct kctl *kctl;
871 TAILQ_FOREACH(kctl, &ctl_head, next) {
872 if (kctl->id == id && (kctl->flags & CTL_FLAG_REG_ID_UNIT) == 0)
873 return kctl;
874 else if (kctl->id == id && kctl->reg_unit == unit)
875 return kctl;
884 kcb_find(struct kctl *kctl, u_int32_t unit)
888 TAILQ_FOREACH(kcb, &kctl->kcb_head, next)