1999-10-21 09:06:11 +00:00
|
|
|
.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
|
|
|
|
.\" All rights reserved.
|
2001-07-14 19:41:16 +00:00
|
|
|
.\"
|
1999-10-21 09:06:11 +00:00
|
|
|
.\" Subject to the following obligations and disclaimer of warranty, use and
|
|
|
|
.\" redistribution of this software, in source or object code forms, with or
|
|
|
|
.\" without modifications are expressly permitted by Whistle Communications;
|
|
|
|
.\" provided, however, that:
|
|
|
|
.\" 1. Any and all reproductions of the source or object code must include the
|
|
|
|
.\" copyright notice above and the following disclaimer of warranties; and
|
|
|
|
.\" 2. No rights are granted, in any manner or form, to use Whistle
|
|
|
|
.\" Communications, Inc. trademarks, including the mark "WHISTLE
|
|
|
|
.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
|
|
|
.\" such appears in the above copyright notice or in the software.
|
2001-07-14 19:41:16 +00:00
|
|
|
.\"
|
1999-10-21 09:06:11 +00:00
|
|
|
.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
|
|
|
.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
|
|
|
.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
|
|
|
.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
|
|
|
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
|
|
|
.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
|
|
|
.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
|
|
|
.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
|
|
|
.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
|
|
|
.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
|
|
|
.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
|
|
.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
|
|
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
.\" THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
|
|
|
.\" OF SUCH DAMAGE.
|
2001-07-14 19:41:16 +00:00
|
|
|
.\"
|
2000-10-26 15:30:44 +00:00
|
|
|
.\" Author: Archie Cobbs <archie@FreeBSD.org>
|
1999-10-21 09:06:11 +00:00
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
1999-10-29 05:56:00 +00:00
|
|
|
.\" $Whistle: ng_pppoe.8,v 1.1 1999/01/25 23:46:27 archie Exp $
|
1999-10-21 09:06:11 +00:00
|
|
|
.\"
|
2018-02-14 21:17:44 +00:00
|
|
|
.Dd February 14, 2018
|
2000-05-04 17:54:37 +00:00
|
|
|
.Dt NG_PPPOE 4
|
2001-07-10 15:31:11 +00:00
|
|
|
.Os
|
1999-10-21 09:06:11 +00:00
|
|
|
.Sh NAME
|
1999-10-29 05:56:00 +00:00
|
|
|
.Nm ng_pppoe
|
2003-12-18 17:27:49 +00:00
|
|
|
.Nd RFC 2516 PPPoE protocol netgraph node type
|
1999-10-21 09:06:11 +00:00
|
|
|
.Sh SYNOPSIS
|
2005-02-05 11:31:31 +00:00
|
|
|
.In sys/types.h
|
2001-10-01 16:09:29 +00:00
|
|
|
.In net/ethernet.h
|
2005-02-05 11:31:31 +00:00
|
|
|
.In netgraph.h
|
2001-10-01 16:09:29 +00:00
|
|
|
.In netgraph/ng_pppoe.h
|
1999-10-21 09:06:11 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
1999-12-21 01:25:21 +00:00
|
|
|
.Nm pppoe
|
2003-12-18 17:31:44 +00:00
|
|
|
node type performs the PPPoE protocol.
|
|
|
|
It is used in conjunction with the
|
1999-11-19 04:40:34 +00:00
|
|
|
.Xr netgraph 4
|
|
|
|
extensions to the Ethernet framework to divert and inject Ethernet packets
|
1999-10-29 05:56:00 +00:00
|
|
|
to and from a PPP agent (which is not specified).
|
1999-10-21 09:06:11 +00:00
|
|
|
.Pp
|
|
|
|
The
|
1999-10-29 05:56:00 +00:00
|
|
|
.Dv NGM_PPPOE_GET_STATUS
|
1999-10-21 09:06:11 +00:00
|
|
|
control message can be used at any time to query the current status
|
2003-12-18 17:31:44 +00:00
|
|
|
of the PPPoE module.
|
|
|
|
The only statistics presently available are the
|
2003-06-28 23:53:39 +00:00
|
|
|
total packet counts for input and output.
|
|
|
|
This node does not yet support
|
1999-10-29 05:56:00 +00:00
|
|
|
the
|
1999-10-21 09:06:11 +00:00
|
|
|
.Dv NGM_TEXT_STATUS
|
|
|
|
control message.
|
|
|
|
.Sh HOOKS
|
|
|
|
This node type supports the following hooks:
|
2012-11-13 20:41:36 +00:00
|
|
|
.Bl -tag -width ".Va [unspecified]"
|
|
|
|
.It Va ethernet
|
2006-08-09 09:56:58 +00:00
|
|
|
The hook that should normally be connected to an
|
|
|
|
.Xr ng_ether 4
|
|
|
|
node.
|
|
|
|
Once connected,
|
|
|
|
.Nm
|
|
|
|
will send a message down this hook to determine Ethernet address of
|
|
|
|
the underlying node.
|
|
|
|
Obtained address will be stored and then used for outgoing datagrams.
|
2012-11-13 20:41:36 +00:00
|
|
|
.It Va debug
|
1999-10-29 05:56:00 +00:00
|
|
|
Presently no use.
|
2012-11-13 20:41:36 +00:00
|
|
|
.It Va [unspecified]
|
1999-10-29 05:56:00 +00:00
|
|
|
Any other name is assumed to be a session hook that will be connected to
|
2003-12-18 17:27:49 +00:00
|
|
|
a PPP client agent, or a PPP server agent.
|
1999-10-21 09:06:11 +00:00
|
|
|
.El
|
|
|
|
.Sh CONTROL MESSAGES
|
|
|
|
This node type supports the generic control messages, plus the following:
|
2004-07-30 11:33:52 +00:00
|
|
|
.Bl -tag -width 3n
|
1999-10-29 05:56:00 +00:00
|
|
|
.It Dv NGM_PPPOE_GET_STATUS
|
1999-10-21 09:06:11 +00:00
|
|
|
This command returns status information in a
|
1999-10-29 05:56:00 +00:00
|
|
|
.Dv "struct ngpppoestat" :
|
1999-10-21 09:06:11 +00:00
|
|
|
.Bd -literal -offset 4n
|
1999-10-29 05:56:00 +00:00
|
|
|
struct ngpppoestat {
|
2003-12-18 17:27:49 +00:00
|
|
|
u_int packets_in; /* packets in from Ethernet */
|
|
|
|
u_int packets_out; /* packets out towards Ethernet */
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.It Dv NGM_TEXT_STATUS
|
2006-09-18 11:04:08 +00:00
|
|
|
This generic message returns a human-readable version of the node status.
|
1999-10-29 05:56:00 +00:00
|
|
|
(not yet)
|
2012-11-13 20:41:36 +00:00
|
|
|
.It Dv NGM_PPPOE_CONNECT Pq Ic pppoe_connect
|
2005-02-13 23:45:54 +00:00
|
|
|
Tell a nominated newly created hook that its session should enter
|
2006-10-22 16:21:55 +00:00
|
|
|
the state machine as a client.
|
2007-12-29 19:59:58 +00:00
|
|
|
It must be newly created and a service name can be given as an argument.
|
|
|
|
It is legal to specify a zero-length service name, this is common
|
2008-01-05 23:41:15 +00:00
|
|
|
on some DSL setups.
|
2018-02-14 21:17:44 +00:00
|
|
|
It is possible to request a connection to a specific access concentrator,
|
|
|
|
and/or set a specific Host-Uniq tag, required by some Internet providers,
|
|
|
|
using the
|
|
|
|
.Qq Li [AC-Name\\][Host-Uniq|]Service-Name
|
|
|
|
syntax.
|
|
|
|
To set a binary Host-Uniq, it must be encoded as a hexadecimal lowercase
|
2020-10-09 19:12:44 +00:00
|
|
|
string and prefixed with
|
2018-02-14 21:17:44 +00:00
|
|
|
.Qq Li 0x ,
|
2020-10-09 19:12:44 +00:00
|
|
|
for example
|
2018-02-14 21:17:44 +00:00
|
|
|
.Qq Li 0x6d792d746167
|
|
|
|
is equivalent to
|
|
|
|
.Qq Li my-tag .
|
|
|
|
A session request packet will be broadcast on the Ethernet.
|
2001-07-14 19:41:16 +00:00
|
|
|
This command uses the
|
1999-10-29 05:56:00 +00:00
|
|
|
.Dv ngpppoe_init_data
|
|
|
|
structure shown below.
|
2018-02-14 21:17:44 +00:00
|
|
|
For example, this init data argument can be used to
|
|
|
|
connect to
|
|
|
|
.Qq Li my-isp
|
|
|
|
service with
|
|
|
|
.Qq Li my-host
|
|
|
|
uniq tag, accepting only
|
|
|
|
.Qq Li remote-ac
|
|
|
|
as access concentrator:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
"remote-ac\\my-host|my-isp"
|
|
|
|
.Ed
|
2012-11-13 20:41:36 +00:00
|
|
|
.It Dv NGM_PPPOE_LISTEN Pq Ic pppoe_listen
|
2005-02-13 23:45:54 +00:00
|
|
|
Tell a nominated newly created hook that its session should enter
|
2006-10-22 16:21:55 +00:00
|
|
|
the state machine as a server listener.
|
2003-06-28 23:53:39 +00:00
|
|
|
The argument
|
2006-10-22 16:21:55 +00:00
|
|
|
given is the name of the service to listen for.
|
|
|
|
A zero-length service name will match all requests for service.
|
2003-06-28 23:53:39 +00:00
|
|
|
A matching service request
|
1999-10-29 05:56:00 +00:00
|
|
|
packet will be passed unmodified back to the process responsible
|
2003-06-28 23:53:39 +00:00
|
|
|
for starting the service.
|
|
|
|
It can then examine it and pass it on to
|
2001-07-14 19:41:16 +00:00
|
|
|
the session that is started to answer the request.
|
|
|
|
This command uses the
|
1999-10-29 05:56:00 +00:00
|
|
|
.Dv ngpppoe_init_data
|
|
|
|
structure shown below.
|
2012-11-13 20:41:36 +00:00
|
|
|
.It Dv NGM_PPPOE_OFFER Pq Ic pppoe_offer
|
2005-02-13 23:45:54 +00:00
|
|
|
Tell a nominated newly created hook that its session should enter
|
2006-10-22 16:21:55 +00:00
|
|
|
the state machine as a server.
|
2003-06-28 23:53:39 +00:00
|
|
|
The argument given is the name of the service to offer.
|
2006-10-22 16:21:55 +00:00
|
|
|
A zero-length service
|
2003-06-28 23:53:39 +00:00
|
|
|
is legal.
|
|
|
|
The State machine will progress to a state where it will await
|
2004-07-03 18:29:24 +00:00
|
|
|
a request packet to be forwarded to it from the startup server,
|
2006-10-22 16:21:55 +00:00
|
|
|
which in turn probably received it from a LISTEN mode hook (see above).
|
1999-10-29 05:56:00 +00:00
|
|
|
This is so
|
|
|
|
that information that is required for the session that is embedded in
|
2001-07-14 19:41:16 +00:00
|
|
|
the original session request packet, is made available to the state machine
|
2003-06-28 23:53:39 +00:00
|
|
|
that eventually answers the request.
|
|
|
|
When the Session request packet is
|
2001-07-14 19:41:16 +00:00
|
|
|
received, the session negotiation will proceed.
|
|
|
|
This command uses the
|
1999-10-29 05:56:00 +00:00
|
|
|
.Dv ngpppoe_init_data
|
|
|
|
structure shown below.
|
2004-07-30 11:33:52 +00:00
|
|
|
.El
|
1999-10-29 05:56:00 +00:00
|
|
|
.Pp
|
1999-11-19 04:40:34 +00:00
|
|
|
The three commands above use a common data structure:
|
1999-10-29 05:56:00 +00:00
|
|
|
.Bd -literal -offset 4n
|
|
|
|
struct ngpppoe_init_data {
|
2003-11-15 15:26:35 +00:00
|
|
|
char hook[NG_HOOKSIZ]; /* hook to monitor on */
|
2012-11-13 20:41:36 +00:00
|
|
|
uint16_t data_len; /* length of the service name */
|
1999-11-19 04:40:34 +00:00
|
|
|
char data[0]; /* init data goes here */
|
1999-10-29 05:56:00 +00:00
|
|
|
};
|
|
|
|
.Ed
|
2004-07-30 11:33:52 +00:00
|
|
|
.Bl -tag -width 3n
|
2012-11-13 20:41:36 +00:00
|
|
|
.It Dv NGM_PPPOE_SUCCESS Pq Ic pppoe_success
|
1999-10-29 05:56:00 +00:00
|
|
|
This command is sent to the node that started this session with one of the
|
2003-06-28 23:53:39 +00:00
|
|
|
above messages, and reports a state change.
|
|
|
|
This message reports successful Session negotiation.
|
|
|
|
It uses the structure shown below, and
|
1999-10-29 05:56:00 +00:00
|
|
|
reports back the hook name corresponding to the successful session.
|
2012-11-13 20:41:36 +00:00
|
|
|
.It Dv NGM_PPPOE_FAIL Pq Ic pppoe_fail
|
1999-10-29 05:56:00 +00:00
|
|
|
This command is sent to the node that started this session with one of the
|
2003-06-28 23:53:39 +00:00
|
|
|
above messages, and reports a state change.
|
|
|
|
This message reports failed Session negotiation.
|
|
|
|
It uses the structure shown below, and
|
1999-10-29 05:56:00 +00:00
|
|
|
reports back the hook name corresponding to the failed session.
|
2006-10-22 16:21:55 +00:00
|
|
|
The hook will probably have been removed immediately after sending this
|
|
|
|
message.
|
2012-11-13 20:41:36 +00:00
|
|
|
.It Dv NGM_PPPOE_CLOSE Pq Ic pppoe_close
|
1999-10-29 05:56:00 +00:00
|
|
|
This command is sent to the node that started this session with one of the
|
2003-12-18 17:31:44 +00:00
|
|
|
above messages, and reports a state change.
|
|
|
|
This message reports a request to close a session.
|
2003-06-28 23:53:39 +00:00
|
|
|
It uses the structure shown below, and
|
1999-10-29 05:56:00 +00:00
|
|
|
reports back the hook name corresponding to the closed session.
|
1999-10-30 20:30:19 +00:00
|
|
|
The hook will probably have been removed immediately after sending this
|
2003-06-28 23:53:39 +00:00
|
|
|
message.
|
2006-10-22 16:21:55 +00:00
|
|
|
At present this message is not yet used and a
|
|
|
|
.Dv NGM_PPPOE_FAIL
|
|
|
|
message
|
1999-10-29 05:56:00 +00:00
|
|
|
will be received at closure instead.
|
2002-02-20 15:55:02 +00:00
|
|
|
.It Dv NGM_PPPOE_ACNAME
|
|
|
|
This command is sent to the node that started this session with one of the
|
|
|
|
above messages, and reports the Access Concentrator Name.
|
2004-07-30 11:33:52 +00:00
|
|
|
.El
|
1999-10-29 05:56:00 +00:00
|
|
|
.Pp
|
2002-02-20 15:55:02 +00:00
|
|
|
The four commands above use a common data structure:
|
1999-10-29 05:56:00 +00:00
|
|
|
.Bd -literal -offset 4n
|
|
|
|
struct ngpppoe_sts {
|
2015-09-15 12:19:01 +00:00
|
|
|
char hook[NG_HOOKSIZ];
|
1999-10-29 05:56:00 +00:00
|
|
|
};
|
2001-01-18 17:23:15 +00:00
|
|
|
.Ed
|
2004-07-30 11:33:52 +00:00
|
|
|
.Bl -tag -width 3n
|
2012-11-13 20:41:36 +00:00
|
|
|
.It Dv NGM_PPPOE_GETMODE Pq Ic pppoe_getmode
|
2006-01-27 11:28:32 +00:00
|
|
|
This command returns the current compatibility mode of the node
|
|
|
|
as a string.
|
|
|
|
.Tn ASCII
|
|
|
|
form of this message is
|
|
|
|
.Qq Li pppoe_getmode .
|
2006-09-18 15:24:20 +00:00
|
|
|
The following keywords can be returned:
|
2006-01-27 11:28:32 +00:00
|
|
|
.Bl -tag -width 3n
|
|
|
|
.It Qq standard
|
|
|
|
The node operates according to RFC 2516.
|
|
|
|
.It Qq 3Com
|
2004-07-29 18:18:26 +00:00
|
|
|
When
|
|
|
|
.Nm
|
2006-01-27 11:28:32 +00:00
|
|
|
is a PPPoE client, it initiates a session encapsulating packets into
|
|
|
|
incorrect 3Com ethertypes.
|
2006-02-01 14:33:14 +00:00
|
|
|
This compatibility option does not affect server mode.
|
2004-07-29 18:18:26 +00:00
|
|
|
In server mode
|
|
|
|
.Nm
|
2006-01-27 11:28:32 +00:00
|
|
|
supports both modes simultaneously, depending on the ethertype, the
|
|
|
|
client used when connecting.
|
|
|
|
.It Qq D-Link
|
|
|
|
When
|
|
|
|
.Nm
|
|
|
|
is a PPPoE server serving only specific Service-Name(s), it will respond
|
|
|
|
to a PADI requests with empty Service-Name tag, returning all available
|
|
|
|
Service-Name(s) on node.
|
|
|
|
This option is necessary for compatibility with D-Link DI-614+ and DI-624+
|
|
|
|
SOHO routers as clients, when serving only specific Service-Name.
|
2006-02-01 14:33:14 +00:00
|
|
|
This compatibility option does not affect client mode.
|
2006-01-27 11:28:32 +00:00
|
|
|
.El
|
2012-11-13 20:41:36 +00:00
|
|
|
.It Dv NGM_PPPOE_SETMODE Pq Ic pppoe_setmode
|
2004-07-29 18:18:26 +00:00
|
|
|
Configure node to the specified mode.
|
2004-07-30 11:33:52 +00:00
|
|
|
The string argument is required.
|
2006-09-18 15:24:20 +00:00
|
|
|
This command understands the same keywords that are returned by the
|
2006-01-27 11:28:32 +00:00
|
|
|
.Dv NGM_PPPOE_GETMODE
|
|
|
|
command.
|
2004-07-29 18:18:26 +00:00
|
|
|
.Tn ASCII
|
2004-07-30 11:33:52 +00:00
|
|
|
form of this message is
|
|
|
|
.Qq Li pppoe_setmode .
|
|
|
|
For example, the following command will configure the node to initiate
|
|
|
|
the next session in the proprietary 3Com mode:
|
2006-01-27 11:56:59 +00:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
ngctl msg fxp0:orphans pppoe_setmode '"3Com"'
|
|
|
|
.Ed
|
2012-11-13 20:41:36 +00:00
|
|
|
.It Dv NGM_PPPOE_SETENADDR Pq Ic setenaddr
|
2006-08-09 09:56:58 +00:00
|
|
|
Set the node Ethernet address for outgoing datagrams.
|
2006-08-10 11:07:11 +00:00
|
|
|
This message is important when a node has failed to obtain an Ethernet
|
|
|
|
address from its peer on the
|
2006-08-09 09:56:58 +00:00
|
|
|
.Dv ethernet
|
|
|
|
hook, or when user wants to override this address with another one.
|
|
|
|
.Tn ASCII
|
|
|
|
form of this message is
|
|
|
|
.Qq Li setenaddr .
|
2015-09-15 12:19:01 +00:00
|
|
|
.It Dv NGM_PPPOE_SETMAXP Pq Ic setmaxp
|
|
|
|
Set the node PPP-Max-Payload value as described in RFC 4638.
|
|
|
|
This message applies only to a client configuration.
|
|
|
|
.Tn ASCII
|
|
|
|
form of this message is
|
|
|
|
.Qq Li setmaxp .
|
|
|
|
.Pp
|
|
|
|
Data structure returned to client is:
|
|
|
|
.Bd -literal -offset 4n
|
|
|
|
struct ngpppoe_maxp {
|
|
|
|
char hook[NG_HOOKSIZ];
|
|
|
|
uint16_t data;
|
|
|
|
};
|
|
|
|
.Ed
|
2018-02-14 21:17:44 +00:00
|
|
|
.It Dv NGM_PPPOE_SEND_HURL Pq Ic send_hurl
|
|
|
|
Tell a nominated hook with an active session to send a PADM message with
|
|
|
|
a HURL tag.
|
|
|
|
The argument is the URL to be delivered to the client:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
ngctl msg fxp0:orphans send_hurl '{ hook="myHook" data="http://example.net/cpe" }'
|
|
|
|
.Ed
|
|
|
|
.It Dv NGM_PPPOE_SEND_MOTM Pq Ic send_motm
|
|
|
|
Tell a nominated hook with an active session to send a PADM message with
|
|
|
|
a MOTM tag.
|
|
|
|
The argument is the message to be delivered to the client:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
ngctl msg fxp0:orphans send_motm '{ hook="myHook" data="Welcome aboard" }'
|
|
|
|
.Ed
|
2004-07-29 18:18:26 +00:00
|
|
|
.El
|
2018-02-14 21:17:44 +00:00
|
|
|
.Pp
|
|
|
|
The two commands above use the same ngpppoe_init_data structure described
|
|
|
|
above.
|
|
|
|
.Bl -tag -width 3n
|
|
|
|
.It Dv NGM_PPPOE_HURL
|
|
|
|
This command is sent to the node that started this session when a PADM
|
|
|
|
message with a HURL tag is received, and contains a URL that the host can
|
|
|
|
pass to a web browser for presentation to the user.
|
|
|
|
.It Dv NGM_PPPOE_MOTM
|
|
|
|
This command is sent to the node that started this session when a PADM
|
|
|
|
message with a MOTM tag is received, and contains a Message Of The
|
|
|
|
Minute that the host can display to the user.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The two commands above use a common data structure:
|
|
|
|
.Bd -literal -offset 4n
|
|
|
|
struct ngpppoe_padm {
|
|
|
|
char msg[PPPOE_PADM_VALUE_SIZE];
|
|
|
|
};
|
|
|
|
.Ed
|
1999-10-21 09:06:11 +00:00
|
|
|
.Sh SHUTDOWN
|
|
|
|
This node shuts down upon receipt of a
|
|
|
|
.Dv NGM_SHUTDOWN
|
1999-10-29 05:56:00 +00:00
|
|
|
control message, when all session have been disconnected or when the
|
|
|
|
.Dv ethernet
|
1999-10-30 20:30:19 +00:00
|
|
|
hook is disconnected.
|
1999-12-21 01:25:21 +00:00
|
|
|
.Sh EXAMPLES
|
2001-07-14 19:41:16 +00:00
|
|
|
The following code uses
|
1999-10-29 05:56:00 +00:00
|
|
|
.Dv libnetgraph
|
|
|
|
to set up a
|
2001-07-14 19:41:16 +00:00
|
|
|
.Nm
|
2003-06-28 23:53:39 +00:00
|
|
|
node and connect it to both a socket node and an Ethernet node.
|
|
|
|
It can handle the case of when a
|
1999-10-29 05:56:00 +00:00
|
|
|
.Nm
|
2003-06-28 23:53:39 +00:00
|
|
|
node is already attached to the Ethernet.
|
|
|
|
It then starts a client session.
|
1999-10-29 05:56:00 +00:00
|
|
|
.Bd -literal
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sysexits.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <err.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <net/ethernet.h>
|
|
|
|
|
|
|
|
#include <netgraph.h>
|
|
|
|
#include <netgraph/ng_ether.h>
|
|
|
|
#include <netgraph/ng_pppoe.h>
|
|
|
|
#include <netgraph/ng_socket.h>
|
|
|
|
static int setup(char *ethername, char *service, char *sessname,
|
|
|
|
int *dfd, int *cfd);
|
|
|
|
|
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
int fd1, fd2;
|
|
|
|
setup("xl0", NULL, "fred", &fd1, &fd2);
|
|
|
|
sleep (30);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
setup(char *ethername, char *service, char *sessname,
|
|
|
|
int *dfd, int *cfd)
|
|
|
|
{
|
|
|
|
struct ngm_connect ngc; /* connect */
|
|
|
|
struct ngm_mkpeer mkp; /* mkpeer */
|
|
|
|
/******** nodeinfo stuff **********/
|
|
|
|
u_char rbuf[2 * 1024];
|
|
|
|
struct ng_mesg *const resp = (struct ng_mesg *) rbuf;
|
|
|
|
struct hooklist *const hlist
|
|
|
|
= (struct hooklist *) resp->data;
|
|
|
|
struct nodeinfo *const ninfo = &hlist->nodeinfo;
|
|
|
|
int ch, no_hooks = 0;
|
|
|
|
struct linkinfo *link;
|
|
|
|
struct nodeinfo *peer;
|
2003-12-18 17:27:49 +00:00
|
|
|
/****message to connect PPPoE session*****/
|
1999-10-29 05:56:00 +00:00
|
|
|
struct {
|
2000-09-13 13:37:48 +00:00
|
|
|
struct ngpppoe_init_data idata;
|
1999-10-29 05:56:00 +00:00
|
|
|
char service[100];
|
|
|
|
} message;
|
|
|
|
/********tracking our little graph ********/
|
|
|
|
char path[100];
|
2003-11-15 15:26:35 +00:00
|
|
|
char source_ID[NG_NODESIZ];
|
1999-10-29 05:56:00 +00:00
|
|
|
char pppoe_node_name[100];
|
|
|
|
int k;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create the data and control sockets
|
|
|
|
*/
|
|
|
|
if (NgMkSockNode(NULL, cfd, dfd) < 0) {
|
|
|
|
return (errno);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* find the ether node of the name requested by asking it for
|
|
|
|
* it's inquiry information.
|
|
|
|
*/
|
|
|
|
if (strlen(ethername) > 16)
|
|
|
|
return (EINVAL);
|
|
|
|
sprintf(path, "%s:", ethername);
|
|
|
|
if (NgSendMsg(*cfd, path, NGM_GENERIC_COOKIE,
|
|
|
|
NGM_LISTHOOKS, NULL, 0) < 0) {
|
|
|
|
return (errno);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* the command was accepted so it exists. Await the reply (It's
|
|
|
|
* almost certainly already waiting).
|
|
|
|
*/
|
|
|
|
if (NgRecvMsg(*cfd, resp, sizeof(rbuf), NULL) < 0) {
|
|
|
|
return (errno);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* The following is available about the node:
|
|
|
|
* ninfo->name (string)
|
|
|
|
* ninfo->type (string)
|
2012-02-12 18:29:56 +00:00
|
|
|
* ninfo->id (uint32_t)
|
|
|
|
* ninfo->hooks (uint32_t) (count of hooks)
|
1999-10-29 05:56:00 +00:00
|
|
|
* check it is the correct type. and get it's ID for use
|
|
|
|
* with mkpeer later.
|
|
|
|
*/
|
|
|
|
if (strncmp(ninfo->type, NG_ETHER_NODE_TYPE,
|
|
|
|
strlen(NG_ETHER_NODE_TYPE)) != 0) {
|
|
|
|
return (EPROTOTYPE);
|
|
|
|
}
|
|
|
|
sprintf(source_ID, "[%08x]:", ninfo->id);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* look for a hook already attached.
|
|
|
|
*/
|
|
|
|
for (k = 0; k < ninfo->hooks; k++) {
|
|
|
|
/**
|
|
|
|
* The following are available about each hook.
|
|
|
|
* link->ourhook (string)
|
|
|
|
* link->peerhook (string)
|
|
|
|
* peer->name (string)
|
|
|
|
* peer->type (string)
|
2012-02-12 18:29:56 +00:00
|
|
|
* peer->id (uint32_t)
|
|
|
|
* peer->hooks (uint32_t)
|
1999-10-29 05:56:00 +00:00
|
|
|
*/
|
|
|
|
link = &hlist->link[k];
|
|
|
|
peer = &hlist->link[k].nodeinfo;
|
|
|
|
|
|
|
|
/* Ignore debug hooks */
|
|
|
|
if (strcmp("debug", link->ourhook) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* If the orphans hook is attached, use that */
|
|
|
|
if (strcmp(NG_ETHER_HOOK_ORPHAN,
|
|
|
|
link->ourhook) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* the other option is the 'divert' hook */
|
|
|
|
if (strcmp("NG_ETHER_HOOK_DIVERT",
|
|
|
|
link->ourhook) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if we found a hook there.
|
|
|
|
*/
|
|
|
|
if (k < ninfo->hooks) {
|
|
|
|
if (strcmp(peer->type, NG_PPPOE_NODE_TYPE) == 0) {
|
|
|
|
/*
|
2003-12-18 17:27:49 +00:00
|
|
|
* If it's a type PPPoE, we skip making one
|
1999-10-29 05:56:00 +00:00
|
|
|
* ourself, but we continue, using
|
|
|
|
* the existing one.
|
|
|
|
*/
|
|
|
|
sprintf(pppoe_node_name, "[%08x]:", peer->id);
|
|
|
|
} else {
|
|
|
|
/*
|
1999-10-30 20:30:19 +00:00
|
|
|
* There is already someone hogging the data,
|
|
|
|
* return an error. Some day we'll try
|
1999-10-29 05:56:00 +00:00
|
|
|
* daisy-chaining..
|
|
|
|
*/
|
|
|
|
return (EBUSY);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/*
|
2003-12-18 17:27:49 +00:00
|
|
|
* Try make a node of type PPPoE against node "ID"
|
1999-10-29 05:56:00 +00:00
|
|
|
* On hook NG_ETHER_HOOK_ORPHAN.
|
|
|
|
*/
|
|
|
|
snprintf(mkp.type, sizeof(mkp.type),
|
|
|
|
"%s", NG_PPPOE_NODE_TYPE);
|
|
|
|
snprintf(mkp.ourhook, sizeof(mkp.ourhook),
|
|
|
|
"%s", NG_ETHER_HOOK_ORPHAN);
|
|
|
|
snprintf(mkp.peerhook, sizeof(mkp.peerhook),
|
|
|
|
"%s", NG_PPPOE_HOOK_ETHERNET);
|
|
|
|
/* Send message */
|
|
|
|
if (NgSendMsg(*cfd, source_ID, NGM_GENERIC_COOKIE,
|
|
|
|
NGM_MKPEER, &mkp, sizeof(mkp)) < 0) {
|
|
|
|
return (errno);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Work out a name for the new node.
|
|
|
|
*/
|
|
|
|
sprintf(pppoe_node_name, "%s:%s",
|
|
|
|
source_ID, NG_ETHER_HOOK_ORPHAN);
|
|
|
|
}
|
|
|
|
/*
|
2003-12-18 17:27:49 +00:00
|
|
|
* We now have a PPPoE node attached to the Ethernet
|
|
|
|
* card. The Ethernet is addressed as ethername: The PPPoE
|
1999-10-29 05:56:00 +00:00
|
|
|
* node is addressed as pppoe_node_name: attach to it.
|
|
|
|
* Connect socket node to specified node Use the same hook
|
|
|
|
* name on both ends of the link.
|
|
|
|
*/
|
|
|
|
snprintf(ngc.path, sizeof(ngc.path), "%s", pppoe_node_name);
|
|
|
|
snprintf(ngc.ourhook, sizeof(ngc.ourhook), "%s", sessname);
|
|
|
|
snprintf(ngc.peerhook, sizeof(ngc.peerhook), "%s", sessname);
|
|
|
|
|
|
|
|
if (NgSendMsg(*cfd, ".:", NGM_GENERIC_COOKIE,
|
|
|
|
NGM_CONNECT, &ngc, sizeof(ngc)) < 0) {
|
|
|
|
return (errno);
|
|
|
|
}
|
2004-07-29 18:18:26 +00:00
|
|
|
|
|
|
|
#ifdef NONSTANDARD
|
|
|
|
/*
|
|
|
|
* In some cases we are speaking to 3Com hardware, so
|
|
|
|
* configure node to non-standard mode.
|
|
|
|
*/
|
|
|
|
if (NgSendMsg(*cfd, ngc.path, NGM_PPPOE_COOKIE,
|
|
|
|
NGM_PPPOE_SETMODE, NG_PPPOE_NONSTANDARD,
|
|
|
|
strlen(NG_PPPOE_NONSTANDARD) + 1) == -1) {
|
|
|
|
return (errno);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-10-29 05:56:00 +00:00
|
|
|
/*
|
|
|
|
* Send it a message telling it to start up.
|
|
|
|
*/
|
|
|
|
bzero(&message, sizeof(message));
|
|
|
|
snprintf(message.idata.hook, sizeof(message.idata.hook),
|
|
|
|
"%s", sessname);
|
|
|
|
if (service == NULL) {
|
|
|
|
message.idata.data_len = 0;
|
|
|
|
} else {
|
|
|
|
snprintf(message.idata.data,
|
|
|
|
sizeof(message.idata.data), "%s", service);
|
|
|
|
message.idata.data_len = strlen(service);
|
|
|
|
}
|
|
|
|
/* Tell session/hook to start up as a client */
|
|
|
|
if (NgSendMsg(*cfd, ngc.path,
|
|
|
|
NGM_PPPOE_COOKIE, NGM_PPPOE_CONNECT, &message.idata,
|
|
|
|
sizeof(message.idata) + message.idata.data_len) < 0) {
|
|
|
|
return (errno);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
.Ed
|
1999-10-21 09:06:11 +00:00
|
|
|
.Sh SEE ALSO
|
1999-10-29 05:56:00 +00:00
|
|
|
.Xr netgraph 3 ,
|
1999-10-21 09:06:11 +00:00
|
|
|
.Xr netgraph 4 ,
|
2006-08-09 09:56:58 +00:00
|
|
|
.Xr ng_ether 4 ,
|
2000-05-04 17:54:37 +00:00
|
|
|
.Xr ng_ppp 4 ,
|
2001-07-06 16:46:48 +00:00
|
|
|
.Xr ng_socket 4 ,
|
2004-07-29 18:18:26 +00:00
|
|
|
.Xr ngctl 8 ,
|
|
|
|
.Xr ppp 8
|
1999-10-21 09:06:11 +00:00
|
|
|
.Rs
|
1999-11-19 04:40:34 +00:00
|
|
|
.%A L. Mamakos
|
|
|
|
.%A K. Lidl
|
|
|
|
.%A J. Evarts
|
|
|
|
.%A D. Carrel
|
|
|
|
.%A D. Simone
|
|
|
|
.%A R. Wheeler
|
|
|
|
.%T "A Method for transmitting PPP over Ethernet (PPPoE)"
|
|
|
|
.%O RFC 2516
|
1999-10-21 09:06:11 +00:00
|
|
|
.Re
|
1999-12-21 01:25:21 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
node type was implemented in
|
|
|
|
.Fx 4.0 .
|
|
|
|
.Sh AUTHORS
|
2014-06-26 21:46:14 +00:00
|
|
|
.An Julian Elischer Aq Mt julian@FreeBSD.org
|