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