1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * PPPoE common utilities and data. 24*7c478bd9Sstevel@tonic-gate * 25*7c478bd9Sstevel@tonic-gate * Copyright (c) 2000-2001 by Sun Microsystems, Inc. 26*7c478bd9Sstevel@tonic-gate * All rights reserved. 27*7c478bd9Sstevel@tonic-gate */ 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #ifndef PPPOE_COMMON_H 30*7c478bd9Sstevel@tonic-gate #define PPPOE_COMMON_H 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 35*7c478bd9Sstevel@tonic-gate extern "C" { 36*7c478bd9Sstevel@tonic-gate #endif 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/socket.h> 40*7c478bd9Sstevel@tonic-gate #include <net/if.h> 41*7c478bd9Sstevel@tonic-gate #include <net/sppptun.h> 42*7c478bd9Sstevel@tonic-gate #include <net/pppoe.h> 43*7c478bd9Sstevel@tonic-gate #include <netinet/if_ether.h> 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate #define PKT_INPUT_LEN PPPOE_MSGMAX 46*7c478bd9Sstevel@tonic-gate #define PKT_OCTL_LEN (sizeof (struct ppptun_control) + 1) 47*7c478bd9Sstevel@tonic-gate #define PKT_OUTPUT_LEN PPPOE_MSGMAX 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate /* Common buffers */ 50*7c478bd9Sstevel@tonic-gate extern uint32_t pkt_input[]; 51*7c478bd9Sstevel@tonic-gate extern uint32_t pkt_octl[]; 52*7c478bd9Sstevel@tonic-gate extern uint32_t pkt_output[]; 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate /* Name of PPPoE tunnel driver */ 55*7c478bd9Sstevel@tonic-gate extern const char tunnam[]; 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate /* Name of application (from argv[0]) */ 58*7c478bd9Sstevel@tonic-gate extern char *myname; 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate /* Ethernet broadcast address */ 61*7c478bd9Sstevel@tonic-gate extern const ether_addr_t ether_bcast; 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate /* General purpose utility functions. */ 64*7c478bd9Sstevel@tonic-gate struct strbuf; 65*7c478bd9Sstevel@tonic-gate extern int strioctl(int fd, int cmd, void *ptr, int ilen, int olen); 66*7c478bd9Sstevel@tonic-gate extern const char *ehost(const ppptun_atype *pap); 67*7c478bd9Sstevel@tonic-gate extern const char *ehost2(const struct ether_addr *ea); 68*7c478bd9Sstevel@tonic-gate extern const char *ihost(uint32_t haddr); 69*7c478bd9Sstevel@tonic-gate extern int hexdecode(char chr); 70*7c478bd9Sstevel@tonic-gate extern const char *mystrerror(int err); 71*7c478bd9Sstevel@tonic-gate extern void myperror(const char *emsg); 72*7c478bd9Sstevel@tonic-gate extern int mygetmsg(int fd, struct strbuf *ctrl, struct strbuf *data, 73*7c478bd9Sstevel@tonic-gate int *flags); 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate /* PPPoE-specific functions. */ 76*7c478bd9Sstevel@tonic-gate extern poep_t *poe_mkheader(void *dptr, uint8_t codeval, int sessionid); 77*7c478bd9Sstevel@tonic-gate extern boolean_t poe_tagcheck(const poep_t *poep, int length, 78*7c478bd9Sstevel@tonic-gate const uint8_t *tptr); 79*7c478bd9Sstevel@tonic-gate extern int poe_add_str(poep_t *poep, uint16_t ttype, const char *str); 80*7c478bd9Sstevel@tonic-gate extern int poe_add_long(poep_t *poep, uint16_t ttype, uint32_t val); 81*7c478bd9Sstevel@tonic-gate extern int poe_two_longs(poep_t *poep, uint16_t ttype, uint32_t val1, 82*7c478bd9Sstevel@tonic-gate uint32_t val2); 83*7c478bd9Sstevel@tonic-gate extern int poe_tag_copy(poep_t *poep, const uint8_t *tagp); 84*7c478bd9Sstevel@tonic-gate extern const char *poe_tagname(uint16_t tagtype); 85*7c478bd9Sstevel@tonic-gate extern const char *poe_codename(uint8_t codetype); 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate /* These are here in case access wrappers are desired. */ 88*7c478bd9Sstevel@tonic-gate #define poe_version_type(p) ((p)->poep_version_type) 89*7c478bd9Sstevel@tonic-gate #define poe_code(p) ((p)->poep_code) 90*7c478bd9Sstevel@tonic-gate #define poe_session_id(p) ntohs((p)->poep_session_id) 91*7c478bd9Sstevel@tonic-gate #define poe_length(p) ntohs((p)->poep_length) 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 94*7c478bd9Sstevel@tonic-gate } 95*7c478bd9Sstevel@tonic-gate #endif 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate #endif /* PPPOE_COMMON_H */ 98