-/* $OpenBSD: dev.c,v 1.87 2021/01/29 11:31:28 ratchov Exp $ */
+/* $OpenBSD: dev.c,v 1.88 2021/01/29 11:36:44 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
d->slot_list = NULL;
for (c = ctlslot_array, i = DEV_NCTLSLOT; i > 0; i--, c++) {
- if (c->dev != d)
+ if (c->opt->dev != d)
continue;
if (c->ops)
c->ops->exit(c->arg);
* allocate at control slot
*/
struct ctlslot *
-ctlslot_new(struct dev *d, struct ctlops *ops, void *arg)
+ctlslot_new(struct opt *o, struct ctlops *ops, void *arg)
{
struct ctlslot *s;
struct ctl *c;
break;
i++;
}
- s->dev = d;
+ s->opt = o;
s->self = 1 << i;
- if (!dev_ref(d))
+ if (!dev_ref(o->dev))
return NULL;
s->ops = ops;
s->arg = arg;
- for (c = d->ctl_list; c != NULL; c = c->next)
+ for (c = o->dev->ctl_list; c != NULL; c = c->next)
c->refs_mask |= s->self;
return s;
}
{
struct ctl *c, **pc;
- pc = &s->dev->ctl_list;
+ pc = &s->opt->dev->ctl_list;
while ((c = *pc) != NULL) {
c->refs_mask &= ~s->self;
if (c->refs_mask == 0) {
pc = &c->next;
}
s->ops = NULL;
- dev_unref(s->dev);
+ dev_unref(s->opt->dev);
}
void
}
for (s = ctlslot_array, i = DEV_NCTLSLOT; i > 0; i--, s++) {
- if (s->dev == d && s->ops)
+ if (s->ops && s->opt->dev == d)
s->ops->sync(s->arg);
}
}
-/* $OpenBSD: dev.h,v 1.35 2021/01/29 11:31:28 ratchov Exp $ */
+/* $OpenBSD: dev.h,v 1.36 2021/01/29 11:36:44 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
struct ctlslot {
struct ctlops *ops;
void *arg;
- struct dev *dev;
+ struct opt *opt;
unsigned int self; /* equal to (1 << index) */
unsigned int mode;
};
* control related functions
*/
void ctl_log(struct ctl *);
-struct ctlslot *ctlslot_new(struct dev *, struct ctlops *, void *);
+struct ctlslot *ctlslot_new(struct opt *, struct ctlops *, void *);
void ctlslot_del(struct ctlslot *);
int dev_setctl(struct dev *, int, int);
int dev_onval(struct dev *, int, int);
-/* $OpenBSD: sock.c,v 1.39 2021/01/29 11:31:28 ratchov Exp $ */
+/* $OpenBSD: sock.c,v 1.40 2021/01/29 11:36:44 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
}
return 0;
}
- f->ctlslot = ctlslot_new(d, &sock_ctlops, f);
+ opt = opt_byname(d, p->opt);
+ if (opt == NULL)
+ return 0;
+ f->ctlslot = ctlslot_new(opt, &sock_ctlops, f);
if (f->ctlslot == NULL) {
if (log_level >= 2) {
sock_log(f);
if (m->u.ctlsub.desc) {
if (!(f->ctlops & SOCK_CTLDESC)) {
ctl = f->ctlslot->self;
- c = f->ctlslot->dev->ctl_list;
+ c = f->ctlslot->opt->dev->ctl_list;
while (c != NULL) {
c->desc_mask |= ctl;
c = c->next;
sock_close(f);
return 0;
}
- if (!dev_setctl(f->ctlslot->dev,
+ if (!dev_setctl(f->ctlslot->opt->dev,
ntohs(m->u.ctlset.addr),
ntohs(m->u.ctlset.val))) {
#ifdef DEBUG
desc = f->ctldesc;
mask = f->ctlslot->self;
size = 0;
- pc = &f->ctlslot->dev->ctl_list;
+ pc = &f->ctlslot->opt->dev->ctl_list;
while ((c = *pc) != NULL) {
if ((c->desc_mask & mask) == 0 ||
(c->refs_mask & mask) == 0) {
}
if (f->ctlslot && (f->ctlops & SOCK_CTLVAL)) {
mask = f->ctlslot->self;
- for (c = f->ctlslot->dev->ctl_list; c != NULL; c = c->next) {
+ for (c = f->ctlslot->opt->dev->ctl_list; c != NULL; c = c->next) {
if ((c->val_mask & mask) == 0)
continue;
c->val_mask &= ~mask;