1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25#ifndef __PPP_DOMAIN_H__
26#define __PPP_DOMAIN_H__
27
28
29/* ppp_domain is self contained */
30#include <sys/sysctl.h>
31#include "ppp_defs.h"
32#include "if_ppplink.h"
33#include "if_ppp.h"
34
35
36#define PPPPROTO_CTL		1		/* control protocol for ifnet layer */
37
38#define PPP_NAME		"PPP"		/* ppp family name */
39
40
41struct sockaddr_ppp {
42    u_int8_t	ppp_len;			/* sizeof(struct sockaddr_ppp) + variable part */
43    u_int8_t	ppp_family;			/* AF_PPPCTL */
44    u_int16_t	ppp_proto;			/* protocol coding address */
45    u_int32_t 	ppp_cookie;			/* one long for protocol with few info */
46    // variable len, the following are protocol specific addresses
47};
48
49
50struct ppp_link_event_data {
51     u_int16_t          lk_index;
52     u_int16_t          lk_unit;
53     char               lk_name[IFNAMSIZ];
54};
55
56/* Define PPP events, as subclass of NETWORK_CLASS events */
57
58#define KEV_PPP_NET_SUBCLASS 	3
59#define KEV_PPP_LINK_SUBCLASS 	4
60
61
62
63#ifdef KERNEL
64
65#include <IOKit/IOLib.h>
66
67int ppp_domain_init();
68int ppp_domain_dispose();
69int ppp_proto_add();
70int ppp_proto_remove();
71
72int ppp_proto_input(void *data, mbuf_t m);
73void ppp_proto_free(void *data);
74
75SYSCTL_DECL(_net_ppp);
76
77/* Logs facilities */
78
79#define LOGDBG(ifp, text) \
80    if (ifnet_flags(ifp) & IFF_DEBUG) {	\
81        IOLog text; 		\
82    }
83
84#define LOGRETURN(err, ret, text) \
85    if (err) {			\
86        IOLog(text, err); \
87        return ret;		\
88    }
89
90#define LOGGOTOFAIL(err, text) \
91    if (err) {			\
92        IOLog(text, err); \
93        goto fail;		\
94    }
95
96#define LOGNULLFAIL(ret, text) \
97    if (ret == 0) {			\
98        IOLog(text); \
99        goto fail;		\
100    }
101
102#ifdef LOGDATA
103#define LOGMBUF(text, m)   {		\
104    short i;				\
105    char *p = mtod((m), u_char *);	\
106    IOLog(text);			\
107    IOLog(" : 0x ");		\
108    for (i = 0; i < (m)->m_len; i++)	\
109       IOLog("%x ", p[i]);	\
110    IOLog("\n");			\
111}
112#else
113#define LOGMBUF(text, m)
114#endif
115
116
117
118/*
119 * PPP queues.
120 */
121struct	pppqueue {
122	mbuf_t head;
123	mbuf_t tail;
124	int	len;
125	int	maxlen;
126	int	drops;
127};
128
129int ppp_qfull(struct pppqueue *pppq);
130void ppp_drop(struct pppqueue *pppq);
131void ppp_enqueue(struct pppqueue *pppq, mbuf_t m);
132mbuf_t ppp_dequeue(struct pppqueue *pppq);
133void ppp_prepend(struct pppqueue *pppq, mbuf_t m);
134
135#endif
136
137#endif
138