natm_proto.c revision 165900
1139823Simp/*- 225603Skjc * Copyright (c) 1996 Charles D. Cranor and Washington University. 325603Skjc * All rights reserved. 425603Skjc * 525603Skjc * Redistribution and use in source and binary forms, with or without 625603Skjc * modification, are permitted provided that the following conditions 725603Skjc * are met: 825603Skjc * 1. Redistributions of source code must retain the above copyright 925603Skjc * notice, this list of conditions and the following disclaimer. 1025603Skjc * 2. Redistributions in binary form must reproduce the above copyright 1125603Skjc * notice, this list of conditions and the following disclaimer in the 1225603Skjc * documentation and/or other materials provided with the distribution. 1325603Skjc * 3. All advertising materials mentioning features or use of this software 1425603Skjc * must display the following acknowledgement: 1525603Skjc * This product includes software developed by Charles D. Cranor and 1625603Skjc * Washington University. 1725603Skjc * 4. The name of the author may not be used to endorse or promote products 1825603Skjc * derived from this software without specific prior written permission. 1925603Skjc * 2025603Skjc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2125603Skjc * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2225603Skjc * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2325603Skjc * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2425603Skjc * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2525603Skjc * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2625603Skjc * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2725603Skjc * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2825603Skjc * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2925603Skjc * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30165900Srwatson * 31165900Srwatson * $NetBSD: natm_proto.c,v 1.3 1996/09/18 00:56:41 chuck Exp $ 3225603Skjc */ 3325603Skjc 3425603Skjc/* 3525603Skjc * protocol layer for access to native mode ATM 3625603Skjc */ 3725603Skjc 38116189Sobrien#include <sys/cdefs.h> 39116189Sobrien__FBSDID("$FreeBSD: head/sys/netnatm/natm_proto.c 165900 2007-01-08 22:30:39Z rwatson $"); 40116189Sobrien 4125603Skjc#include <sys/param.h> 4225603Skjc#include <sys/systm.h> 4325603Skjc#include <sys/kernel.h> 4425603Skjc#include <sys/socket.h> 4525603Skjc#include <sys/protosw.h> 4625603Skjc#include <sys/domain.h> 4725603Skjc 4825603Skjc#include <net/if.h> 49111888Sjlemon#include <net/netisr.h> 5025603Skjc 5125603Skjc#include <netinet/in.h> 5225603Skjc 5325603Skjc#include <netnatm/natm.h> 5425603Skjc 5592745Salfredstatic void natm_init(void); 5625603Skjc 57149848Sobrienstatic struct domain natmdomain; 58149848Sobrien 5933181Seivindstatic struct protosw natmsw[] = { 60152242Sru{ 61152242Sru .pr_type = SOCK_STREAM, 62152242Sru .pr_domain = &natmdomain, 63152242Sru .pr_protocol = PROTO_NATMAAL5, 64152242Sru .pr_flags = PR_CONNREQUIRED, 65152242Sru .pr_usrreqs = &natm_usrreqs 6625603Skjc}, 67152242Sru{ 68152242Sru .pr_type = SOCK_DGRAM, 69152242Sru .pr_domain = &natmdomain, 70152242Sru .pr_protocol = PROTO_NATMAAL5, 71152242Sru .pr_flags = PR_CONNREQUIRED|PR_ATOMIC, 72152242Sru .pr_usrreqs = &natm_usrreqs 7325603Skjc}, 74152242Sru{ 75152242Sru .pr_type = SOCK_STREAM, 76152242Sru .pr_domain = &natmdomain, 77152242Sru .pr_protocol = PROTO_NATMAAL0, 78152242Sru .pr_flags = PR_CONNREQUIRED, 79152242Sru .pr_usrreqs = &natm_usrreqs 8025603Skjc}, 8125603Skjc}; 8225603Skjc 83152242Srustatic struct domain natmdomain = { 84152242Sru .dom_family = AF_NATM, 85152242Sru .dom_name = "natm", 86152242Sru .dom_init = natm_init, 87152242Sru .dom_protosw = natmsw, 88152242Sru .dom_protoswNPROTOSW = &natmsw[sizeof(natmsw)/sizeof(natmsw[0])], 89152242Sru}; 9025603Skjc 91118541Shartistatic int natmqmaxlen = 1000 /* IFQ_MAXLEN */; /* max # of packets on queue */ 92111888Sjlemonstatic struct ifqueue natmintrq; 9325603Skjc#ifdef NATM_STAT 94118541Shartiu_int natm_sodropcnt; /* # mbufs dropped due to full sb */ 95118541Shartiu_int natm_sodropbytes; /* # of bytes dropped */ 96118541Shartiu_int natm_sookcnt; /* # mbufs ok */ 97118541Shartiu_int natm_sookbytes; /* # of bytes ok */ 9825603Skjc#endif 9925603Skjc 100118541Shartistatic void 101118541Shartinatm_init(void) 10225603Skjc{ 103118541Sharti LIST_INIT(&natm_pcbs); 104118541Sharti bzero(&natmintrq, sizeof(natmintrq)); 105118541Sharti natmintrq.ifq_maxlen = natmqmaxlen; 106148125Srwatson NATM_LOCK_INIT(); 107118541Sharti mtx_init(&natmintrq.ifq_mtx, "natm_inq", NULL, MTX_DEF); 108148125Srwatson netisr_register(NETISR_NATM, natmintr, &natmintrq, NETISR_MPSAFE); 10925603Skjc} 11025603Skjc 11125603SkjcDOMAIN_SET(natm); 112