nd.c (7c478bd9) | nd.c (f4b3ec61) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the |
5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. | 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. |
8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* | 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21/* |
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. | 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. |
24 * Use is subject to license terms. 25 */ 26/* Copyright (c) 1990 Mentat Inc. */ 27 28#pragma ident "%Z%%M% %I% %E% SMI" 29 30#include <sys/types.h> 31#include <sys/systm.h> --- 104 unchanged lines hidden (view full) --- 136 } 137 iocp->ioc_count = size_out; 138 } 139 break; 140 141 case ND_SET: 142 if (valp) { 143 if ((iocp->ioc_cr != NULL) && | 23 * Use is subject to license terms. 24 */ 25/* Copyright (c) 1990 Mentat Inc. */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29#include <sys/types.h> 30#include <sys/systm.h> --- 104 unchanged lines hidden (view full) --- 135 } 136 iocp->ioc_count = size_out; 137 } 138 break; 139 140 case ND_SET: 141 if (valp) { 142 if ((iocp->ioc_cr != NULL) && |
144 ((err = secpolicy_net_config(iocp->ioc_cr, B_FALSE)) | 143 ((err = secpolicy_ip_config(iocp->ioc_cr, B_FALSE)) |
145 == 0)) { 146 err = (*nde->nde_set_pfi)(q, mp1, valp, 147 nde->nde_data, iocp->ioc_cr); 148 } 149 iocp->ioc_count = 0; 150 freemsg(mp1); 151 mp->b_cont = NULL; 152 } --- 63 unchanged lines hidden (view full) --- 216} 217 218/* 219 * Load 'name' into the named dispatch table pointed to by 'ndp'. 220 * 'ndp' should be the address of a char pointer cell. If the table 221 * does not exist (*ndp == 0), a new table is allocated and 'ndp' 222 * is stuffed. If there is not enough space in the table for a new 223 * entry, more space is allocated. | 144 == 0)) { 145 err = (*nde->nde_set_pfi)(q, mp1, valp, 146 nde->nde_data, iocp->ioc_cr); 147 } 148 iocp->ioc_count = 0; 149 freemsg(mp1); 150 mp->b_cont = NULL; 151 } --- 63 unchanged lines hidden (view full) --- 215} 216 217/* 218 * Load 'name' into the named dispatch table pointed to by 'ndp'. 219 * 'ndp' should be the address of a char pointer cell. If the table 220 * does not exist (*ndp == 0), a new table is allocated and 'ndp' 221 * is stuffed. If there is not enough space in the table for a new 222 * entry, more space is allocated. |
223 * Never fails due to memory allocation failures. |
|
224 */ 225boolean_t 226nd_load(caddr_t *nd_pparam, char *name, ndgetf_t get_pfi, ndsetf_t set_pfi, 227 caddr_t data) 228{ 229 ND *nd; 230 NDE *nde; 231 232 if (!nd_pparam) 233 return (B_FALSE); 234 if ((nd = (ND *)(*nd_pparam)) == NULL) { | 224 */ 225boolean_t 226nd_load(caddr_t *nd_pparam, char *name, ndgetf_t get_pfi, ndsetf_t set_pfi, 227 caddr_t data) 228{ 229 ND *nd; 230 NDE *nde; 231 232 if (!nd_pparam) 233 return (B_FALSE); 234 if ((nd = (ND *)(*nd_pparam)) == NULL) { |
235 if ((nd = (ND *)mi_alloc(sizeof (ND), BPRI_MED)) == NULL) 236 return (B_FALSE); | 235 nd = (ND *)mi_alloc_sleep(sizeof (ND), BPRI_MED); |
237 bzero((caddr_t)nd, sizeof (ND)); 238 *nd_pparam = (caddr_t)nd; 239 } 240 if (nd->nd_tbl) { 241 for (nde = nd->nd_tbl; nde->nde_name; nde++) { 242 if (mi_strcmp(name, nde->nde_name) == 0) 243 goto fill_it; 244 } 245 } 246 if (nd->nd_free_count <= 1) { | 236 bzero((caddr_t)nd, sizeof (ND)); 237 *nd_pparam = (caddr_t)nd; 238 } 239 if (nd->nd_tbl) { 240 for (nde = nd->nd_tbl; nde->nde_name; nde++) { 241 if (mi_strcmp(name, nde->nde_name) == 0) 242 goto fill_it; 243 } 244 } 245 if (nd->nd_free_count <= 1) { |
247 if ((nde = (NDE *)mi_alloc(nd->nd_size + 248 NDE_ALLOC_SIZE, BPRI_MED)) == NULL) 249 return (B_FALSE); | 246 nde = (NDE *)mi_alloc_sleep(nd->nd_size + 247 NDE_ALLOC_SIZE, BPRI_MED); |
250 bzero((char *)nde, nd->nd_size + NDE_ALLOC_SIZE); 251 nd->nd_free_count += NDE_ALLOC_COUNT; 252 if (nd->nd_tbl) { 253 bcopy((char *)nd->nd_tbl, (char *)nde, nd->nd_size); 254 mi_free((char *)nd->nd_tbl); 255 } else { 256 nd->nd_free_count--; 257 nde->nde_name = "?"; --- 66 unchanged lines hidden --- | 248 bzero((char *)nde, nd->nd_size + NDE_ALLOC_SIZE); 249 nd->nd_free_count += NDE_ALLOC_COUNT; 250 if (nd->nd_tbl) { 251 bcopy((char *)nd->nd_tbl, (char *)nde, nd->nd_size); 252 mi_free((char *)nd->nd_tbl); 253 } else { 254 nd->nd_free_count--; 255 nde->nde_name = "?"; --- 66 unchanged lines hidden --- |