xref: /titanic_44/usr/src/cmd/cmd-inet/usr.lib/pppoe/common.h (revision 45405cce0657d01714b3d014a0facf3bdce45736)
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.
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 /*
23  * PPPoE common utilities and data.
24  *
25  * Copyright (c) 2000-2001 by Sun Microsystems, Inc.
26  * All rights reserved.
27  */
28 
29 #ifndef PPPOE_COMMON_H
30 #define	PPPOE_COMMON_H
31 
32 #pragma ident	"%Z%%M%	%I%	%E% SMI"
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 #include <sys/types.h>
39 #include <sys/socket.h>
40 #include <net/if.h>
41 #include <net/sppptun.h>
42 #include <net/pppoe.h>
43 #include <netinet/if_ether.h>
44 
45 #define	PKT_INPUT_LEN	PPPOE_MSGMAX
46 #define	PKT_OCTL_LEN	(sizeof (struct ppptun_control) + 1)
47 #define	PKT_OUTPUT_LEN	PPPOE_MSGMAX
48 
49 /* Common buffers */
50 extern uint32_t pkt_input[];
51 extern uint32_t pkt_octl[];
52 extern uint32_t pkt_output[];
53 
54 /* Name of PPPoE tunnel driver */
55 extern const char tunnam[];
56 
57 /* Name of application (from argv[0]) */
58 extern char *myname;
59 
60 /* Ethernet broadcast address */
61 extern const ether_addr_t ether_bcast;
62 
63 /* General purpose utility functions. */
64 struct strbuf;
65 extern int strioctl(int fd, int cmd, void *ptr, int ilen, int olen);
66 extern const char *ehost(const ppptun_atype *pap);
67 extern const char *ehost2(const struct ether_addr *ea);
68 extern const char *ihost(uint32_t haddr);
69 extern int hexdecode(char chr);
70 extern const char *mystrerror(int err);
71 extern void myperror(const char *emsg);
72 extern int mygetmsg(int fd, struct strbuf *ctrl, struct strbuf *data,
73     int *flags);
74 
75 /* PPPoE-specific functions. */
76 extern poep_t *poe_mkheader(void *dptr, uint8_t codeval, int sessionid);
77 extern boolean_t poe_tagcheck(const poep_t *poep, int length,
78     const uint8_t *tptr);
79 extern int poe_add_str(poep_t *poep, uint16_t ttype, const char *str);
80 extern int poe_add_long(poep_t *poep, uint16_t ttype, uint32_t val);
81 extern int poe_two_longs(poep_t *poep, uint16_t ttype, uint32_t val1,
82     uint32_t val2);
83 extern int poe_tag_copy(poep_t *poep, const uint8_t *tagp);
84 extern const char *poe_tagname(uint16_t tagtype);
85 extern const char *poe_codename(uint8_t codetype);
86 
87 /* These are here in case access wrappers are desired. */
88 #define	poe_version_type(p)	((p)->poep_version_type)
89 #define	poe_code(p)		((p)->poep_code)
90 #define	poe_session_id(p)	ntohs((p)->poep_session_id)
91 #define	poe_length(p)		ntohs((p)->poep_length)
92 
93 #ifdef	__cplusplus
94 }
95 #endif
96 
97 #endif /* PPPOE_COMMON_H */
98