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$");
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
91193219Srwatsonstatic struct netisr_handler natm_nh = {
92193219Srwatson	.nh_name = "natm",
93193219Srwatson	.nh_handler = natmintr,
94193219Srwatson	.nh_proto = NETISR_NATM,
95193219Srwatson	.nh_qlimit = 1000,
96193219Srwatson	.nh_policy = NETISR_POLICY_SOURCE,
97193219Srwatson};
98193219Srwatson
9925603Skjc#ifdef NATM_STAT
100118541Shartiu_int natm_sodropcnt;		/* # mbufs dropped due to full sb */
101118541Shartiu_int natm_sodropbytes;		/* # of bytes dropped */
102118541Shartiu_int natm_sookcnt;		/* # mbufs ok */
103118541Shartiu_int natm_sookbytes;		/* # of bytes ok */
10425603Skjc#endif
10525603Skjc
106118541Shartistatic void
107118541Shartinatm_init(void)
10825603Skjc{
109118541Sharti	LIST_INIT(&natm_pcbs);
110148125Srwatson	NATM_LOCK_INIT();
111193219Srwatson	netisr_register(&natm_nh);
11225603Skjc}
11325603Skjc
11425603SkjcDOMAIN_SET(natm);
115