pppoe.c revision f53eecf557986dac6ededb388fedd6ca63be0350
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * See the License for the specific language governing permissions * and limitations under the License. * When distributing Covered Code, include this CDDL HEADER in each * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * pppoe.c - pppd plugin to handle PPPoE operation. /* Saved hook pointers */ /* Room for 3 IPv4 addresses and metric */ /* Environment string for routes */ * wrapper for STREAMS I_STR ioctl. * If the user named the tunneling device, check that it is * reasonable; otherwise check that standard input is the tunnel. int tstfd;
/* fd for device being checked */ int err;
/* saved errno value */ int retv;
/* return value */ int intv;
/* integer return value (from ioctl) */ * Open as real user so that modes on device can be * When we're about to call one of the up or down scripts, change the * second argument to contain the interface name and selected PPPoE * Concatenate and save strings from command line into environment * Convert Message Of The Moment (MOTM) and Host Uniform Resource * Locator (HURL) strings into environment variables and command-line /* Must have room for two strings and NULL terminator. */ error(
"cannot malloc PPPoE message");
* Convert IP Route Add structures into environment variables and * command-line arguments for script. /* Must have room for four strings and NULL terminator. */ error(
"cannot malloc PPPoE route");
/* No alignment restrictions on source; copy to local. */ /* Save off the environment variable version of this. */ * If we get here, then the driver has already validated the sender, * the PPPoE version, the message length, and session ID. The code * number is known not to be zero. * Warning: the data->buf pointer here is not necessarily properly * aligned for access to the poep_session_id or poep_length members. dbglog(
"received PPPoE PADT; connection has been closed");
/* Active Discovery Message and Network extensions */ /* Note: strdup doesn't handle NULL input. */ /* Free storage allocated by handle_{motm_hurl,ip_route_add} */ * Handle an action code passed up from the driver. * sys-solaris has just read in a packet; grovel through it and see if * it's something we need to handle ourselves. /* ptc_discrim is the first uint32_t of the structure. */ /* Forward along to other plug-ins */ * Get an environment variable from the chat script. * Read environment variables exported by chat script. fatal(
"unable to open environment file: %m");