1 2/* 3 * ng_base.c 4 * 5 * Copyright (c) 1996-1999 Whistle Communications, Inc. 6 * All rights reserved. 7 * 8 * Subject to the following obligations and disclaimer of warranty, use and --- 23 unchanged lines hidden (view full) --- 32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 35 * OF SUCH DAMAGE. 36 * 37 * Authors: Julian Elischer <julian@freebsd.org> 38 * Archie Cobbs <archie@freebsd.org> 39 * |
40 * $FreeBSD: head/sys/netgraph/ng_base.c 70159 2000-12-18 20:03:32Z julian $ |
41 * $Whistle: ng_base.c,v 1.39 1999/01/28 23:54:53 julian Exp $ 42 */ 43 44/* 45 * This file implements the base netgraph code. 46 */ 47 48#include <sys/param.h> --- 802 unchanged lines hidden (view full) --- 851 * Install a new netgraph type 852 */ 853int 854ng_newtype(struct ng_type *tp) 855{ 856 const size_t namelen = strlen(tp->name); 857 858 /* Check version and type name fields */ |
859 if ((tp->version != NG_ABI_VERSION) 860 || (namelen == 0) 861 || (namelen > NG_TYPELEN)) { |
862 TRAP_ERROR; 863 return (EINVAL); 864 } 865 866 /* Check for name collision */ 867 if (ng_findtype(tp->name) != NULL) { 868 TRAP_ERROR; 869 return (EEXIST); --- 616 unchanged lines hidden (view full) --- 1486 binary = (struct ng_mesg *)msg->data; 1487 if (msg->header.arglen < sizeof(struct ng_mesg) 1488 || msg->header.arglen - sizeof(struct ng_mesg) 1489 < binary->header.arglen) { 1490 error = EINVAL; 1491 break; 1492 } 1493 |
1494 /* Check response pointer */ 1495 if (resp == NULL) { 1496 error = EINVAL; 1497 break; 1498 } 1499 |
1500 /* Get a response message with lots of room */ 1501 NG_MKRESPONSE(rp, msg, sizeof(*ascii) + bufSize, M_NOWAIT); 1502 if (rp == NULL) { 1503 error = ENOMEM; 1504 break; 1505 } 1506 ascii = (struct ng_mesg *)rp->data; 1507 --- 60 unchanged lines hidden (view full) --- 1568 || ascii->header.arglen < 1 1569 || msg->header.arglen 1570 < sizeof(*ascii) + ascii->header.arglen) { 1571 error = EINVAL; 1572 break; 1573 } 1574 ascii->data[ascii->header.arglen - 1] = '\0'; 1575 |
1576 /* Check response pointer */ 1577 if (resp == NULL) { 1578 error = EINVAL; 1579 break; 1580 } 1581 |
1582 /* Get a response message with lots of room */ 1583 NG_MKRESPONSE(rp, msg, sizeof(*binary) + bufSize, M_NOWAIT); 1584 if (rp == NULL) { 1585 error = ENOMEM; 1586 break; 1587 } 1588 binary = (struct ng_mesg *)rp->data; 1589 --- 507 unchanged lines hidden --- |