/* ------------------------------------------------------------------------ */ int ipf_proxy_ioctl(ipf_main_softc_t *softc, void *data, ioctlcmd_t cmd, int mode, void *ctx) { ap_ctl_t ctl; void *ptr; int error; mode = mode; /* LINT */ switch (cmd) { case SIOCPROXY : error = ipf_inobj(softc, data, NULL, &ctl, IPFOBJ_PROXYCTL); if (error != 0) { return error; } ptr = NULL; if (ctl.apc_dsize > 0) { KMALLOCS(ptr, void *, ctl.apc_dsize); if (ptr == NULL) { IPFERROR(80003); error = ENOMEM; } else { error = copyinptr(softc, ctl.apc_data, ptr, ctl.apc_dsize); if (error == 0) ctl.apc_data = ptr; } } else {
int ipsc_add(caddr_t data) { ipscan_t *i, *isc; int err; KMALLOC(isc, ipscan_t *); if (!isc) return ENOMEM; err = copyinptr(data, isc, sizeof(*isc)); if (err) { KFREE(isc); return err; } WRITE_ENTER(&ipsc_rwlock); i = ipsc_lookup(isc->ipsc_tag); if (i) { RWLOCK_EXIT(&ipsc_rwlock); KFREE(isc); return EEXIST; } if (ipsc_tail) { ipsc_tail->ipsc_next = isc; isc->ipsc_pnext = &ipsc_tail->ipsc_next; ipsc_tail = isc; } else { ipsc_list = isc; ipsc_tail = isc; isc->ipsc_pnext = &ipsc_list; } isc->ipsc_next = NULL; isc->ipsc_hits = 0; isc->ipsc_fref = 0; isc->ipsc_sref = 0; isc->ipsc_active = 0; ipsc_stat.iscs_entries++; RWLOCK_EXIT(&ipsc_rwlock); return 0; }
int ipsc_delete(caddr_t data) { ipscan_t isc, *i; int err; err = copyinptr(data, &isc, sizeof(isc)); if (err) return err; WRITE_ENTER(&ipsc_rwlock); i = ipsc_lookup(isc.ipsc_tag); if (i == NULL) err = ENOENT; else { if (i->ipsc_fref) { RWLOCK_EXIT(&ipsc_rwlock); return EBUSY; } *i->ipsc_pnext = i->ipsc_next; if (i->ipsc_next) i->ipsc_next->ipsc_pnext = i->ipsc_pnext; else { if (i->ipsc_pnext == &ipsc_list) ipsc_tail = NULL; else ipsc_tail = *(*i->ipsc_pnext)->ipsc_pnext; } ipsc_stat.iscs_entries--; KFREE(i); } RWLOCK_EXIT(&ipsc_rwlock); return err; }