xref: /openbsd-src/share/man/man4/pipex.4 (revision ae3cb403620ab940fbaabb3055fac045a63d56b7)
1.\"	$OpenBSD: pipex.4,v 1.11 2017/04/18 03:21:48 yasuoka Exp $
2.\"
3.\" Copyright (c) 2012 YASUOKA Masahiko <yasuoka@openbsd.org>
4.\" Copyright (c) 2010 SUENAGA Hiroki <hsuenaga@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: April 18 2017 $
19.Dt PIPEX 4
20.Os
21.Sh NAME
22.Nm pipex
23.Nd PPP IP EXtension to handle IP/PPP frames in-kernel
24.Sh SYNOPSIS
25.Cd "option PIPEX"
26.Pp
27.In sys/types.h
28.In sys/socket.h
29.In sys/ioctl.h
30.In net/if.h
31.In net/pipex.h
32.Sh DESCRIPTION
33.Nm
34is used with
35.Xr tun 4
36and
37.Xr pppx 4 ,
38and handles PPP frames and forwards IP packets in-kernel.
39It accelerates the performance of packet forwarding, because it reduces
40copying of packets between kernel and userland.
41.Nm
42is disabled by default.
43To enable it, set
44.Va net.pipex.enable
45to
46.Sq 1
47using
48.Xr sysctl 8 .
49.Pp
50.Nm
51adds some extensions to the
52.Xr ioctl 2
53requests to
54.Xr tun 4
55or
56.Xr pppx 4
57devices.
58The added requests are as follows:
59.Bl -tag -width Ds
60.It Dv PIPEXGMODE    Fa "int *"
61Get the devices's
62.Nm
63operation mode.
641 to enable
65.Nm
66on this device; 0 to disable.
67.It Dv PIPEXSMODE    Fa "int *"
68Set the device's
69.Nm
70operation mode.
711 to enable
72.Nm
73on this device; 0 to disable.
74.It Dv PIPEXASESSION Fa "struct pipex_session_req *"
75Add a new PPP session to be handled by
76.Nm .
77The status of the session is passed as a
78.Vt pipex_session_req
79structure.
80The
81.Vt pipex_session_req
82structure has the following definition:
83.Bd -literal
84struct pipex_session_req {
85    int         pr_protocol;         /* tunnel protocol  */
86#define PIPEX_PROTO_L2TP   1         /* protocol L2TP */
87#define PIPEX_PROTO_PPTP   2         /* protocol PPTP */
88#define PIPEX_PROTO_PPPOE  3         /* protocol PPPoE */
89    uint16_t    pr_session_id;       /* session-id */
90    uint16_t    pr_peer_session_id;  /* peer's session-id */
91    uint32_t    pr_ppp_flags;        /* ppp configuration flags */
92#define PIPEX_PPP_ACFC_ACCEPTED  0x0001 /* ACFC accepted */
93#define PIPEX_PPP_PFC_ACCEPTED   0x0002 /* PFC accepted */
94#define PIPEX_PPP_ACFC_ENABLED   0x0004 /* ACFC enabled */
95#define PIPEX_PPP_PFC_ENABLED    0x0008 /* PFC enabled */
96#define PIPEX_PPP_MPPE_ACCEPTED  0x0010 /* MPPE accepted */
97#define PIPEX_PPP_MPPE_ENABLED   0x0020 /* MPPE enabled */
98#define PIPEX_PPP_MPPE_REQUIRED  0x0040 /* MPPE is required */
99#define PIPEX_PPP_HAS_ACF        0x0080 /* has ACF */
100#define PIPEX_PPP_ADJUST_TCPMSS  0x0100 /* do tcpmss adjustment */
101#define PIPEX_PPP_INGRESS_FILTER 0x0200 /* do ingress filter */
102    int8_t      pr_ccp_id;           /* ccp current packet id */
103    int         pr_ppp_id;           /* ppp id. */
104    uint16_t    pr_peer_mru;         /* peer's mru */
105    uint16_t    pr_timeout_sec;      /* idle timer */
106
107    struct in_addr      pr_ip_srcaddr;    /* local IP address.
108					     not used by tun(4) */
109    struct in_addr      pr_ip_address;    /* framed IP address */
110    struct in_addr      pr_ip_netmask;    /* framed IP netmask */
111    struct sockaddr_in6 pr_ip6_address;   /* framed IPv6 address */
112    int                 pr_ip6_prefixlen; /* framed IPv6 prefix
113                                             length */
114    union {
115        struct {
116            uint32_t snd_nxt;         /* send next */
117            uint32_t rcv_nxt;         /* receive next */
118            uint32_t snd_una;         /* unacked */
119            uint32_t rcv_acked;       /* recv acked */
120            int winsz;                /* window size */
121            int maxwinsz;             /* max window size */
122            int peer_maxwinsz;        /* peer's max window size */
123        } pptp;
124        struct {
125            /* select protocol options: 1 for enable */
126            uint32_t option_flags;
127    #define PIPEX_L2TP_USE_SEQUENCING  0x00000001
128                                      /* use sequence number
129					 on L2TP data messages */
130
131            uint16_t tunnel_id;       /* our tunnel-id */
132            uint16_t peer_tunnel_id;  /* peer's tunnel-id */
133            uint32_t ns_nxt;          /* send next */
134            uint32_t nr_nxt;          /* receive next */
135            uint32_t ns_una;          /* unacked */
136            uint32_t nr_acked;        /* recv acked */
137            uint32_t ipsecflowinfo;   /* IPsec flow id for NAT-T */
138        } l2tp;
139        struct {
140            char over_ifname[IF_NAMESIZE];
141                                      /* ethernet ifname */
142        } pppoe;
143    } pr_proto;
144    struct sockaddr_storage  pr_peer_address;
145                                      /* peer address of tunnel */
146    struct sockaddr_storage  pr_local_address;
147				      /* our address of tunnel */
148    struct pipex_mppe_req    pr_mppe_recv;
149				      /* mppe key for receive */
150    struct pipex_mppe_req    pr_mppe_send;
151				      /* mppe key for send */
152};
153.Ed
154.Pp
155The
156.Vt pipex_mppe_req
157structure that was used by
158.Va pr_mppe_recv
159and
160.Va pr_mppe_send
161has the following definition:
162.Bd -literal
163struct pipex_mppe_req {
164    int16_t  stateless;            /* mppe key mode.
165                                      1 for stateless */
166    int16_t  keylenbits;           /* mppe key length(in bits)*/
167    u_char   master_key[PIPEX_MPPE_KEYLEN];
168                                   /* mppe master key */
169};
170.Ed
171.It Dv PIPEXDSESSION Fa "struct pipex_session_close_req *"
172Delete the specified session from the kernel.
173Specify the session using a
174.Vt pipex_session_stat_req
175structure, which has the following definition:
176.Bd -literal
177struct pipex_session_stat_req {
178    int                      psr_protocol;   /* tunnel protocol */
179    uint16_t                 psr_session_id; /* session-id */
180    struct pipex_statistics  psr_stat;       /* statistics */
181};
182.Ed
183.Pp
184The
185.Va psr_protocol
186and
187.Va psr_session_id
188fields used to specify the session are mandatory.
189On successful return, the
190.Va psr_stat
191field is filled by the kernel.
192See
193.Dv PIPEXGSTAT
194section for a description of the
195.Vt pipex_statistics
196structure.
197.It Dv PIPEXCSESSION Fa "struct pipex_session_config_req *"
198Change the configuration of the specified session.
199The session and configuration are specified by a
200.Vt pipex_session_config_req
201structure, which has the following definition:
202.Bd -literal
203struct pipex_session_config_req {
204    int       pcr_protocol;           /* tunnel protocol  */
205    uint16_t  pcr_session_id;         /* session-id */
206    int       pcr_ip_forward;         /* ip_forwarding on/off */
207};
208.Ed
209.It Dv PIPEXGSTAT    Fa "struct pipex_session_stat_req *"
210Get statistics for the specified session.
211Specify the session using a
212.Vt pipex_session_stat_req
213structure, which has the following definition:
214.Bd -literal
215struct pipex_session_stat_req {
216    int                      psr_protocol;   /* tunnel protocol */
217    uint16_t                 psr_session_id; /* session-id */
218    struct pipex_statistics  psr_stat;       /* statistics */
219};
220.Ed
221.Pp
222The
223.Va psr_protocol
224and
225.Va psr_session_id
226fields used to specify the session are mandatory.
227On successful return, the
228.Va psr_stat
229field is filled by the kernel.
230The
231.Vt pipex_statistics
232structure has the following definition:
233.Bd -literal
234struct pipex_statistics {
235    uint32_t ipackets;   /* packets received from tunnel */
236    uint32_t ierrors;    /* error packets received from tunnel */
237    uint64_t ibytes;     /* number of received bytes from tunnel */
238    uint32_t opackets;   /* packets sent to tunnel */
239    uint32_t oerrors;    /* error packets on sending to tunnel */
240    uint64_t obytes;     /* number of sent bytes to tunnel */
241
242    uint32_t idle_time;  /* idle time in seconds */
243};
244.Ed
245.It Dv PIPEXGCLOSED  Fa "struct pipex_session_list_req *"
246Get a list of closed sessions.
247.Nm
248reserves closed sessions for 30 seconds
249for userland programs to get statistical information.
250On successful return,
251the
252.Vt pipex_session_list_req
253structure is filled by the kernel.
254The structure has the following definition.
255.Bd -literal
256struct pipex_session_list_req {
257    uint8_t  plr_flags;
258#define PIPEX_LISTREQ_MORE         0x01      /* has more session */
259    int      plr_ppp_id_count;               /* count of PPP id */
260    int      plr_ppp_id[PIPEX_MAX_LISTREQ];  /* PPP id */
261};
262.Ed
263.It Dv PIPEXSIFDESCR Fa "struct pipex_session_descr_req *"
264Set the
265.Xr pppx 4
266interface's description of the session.
267This command doesn't work on
268.Xr tun 4
269devices.
270Specify the session and its description using a
271.Vt pipex_session_descr_req
272structure, which has the following definition:
273.Bd -literal
274struct pipex_session_descr_req {
275    int       pdr_protocol;           /* tunnel protocol */
276    uint16_t  pdr_session_id;         /* session-id */
277    char      pdr_descr[IFDESCRSIZE]; /* description */
278};
279.Ed
280.El
281.Sh SEE ALSO
282.Xr ioctl 2 ,
283.Xr pppx 4 ,
284.Xr tun 4 ,
285.Xr npppd 8 ,
286.Xr sysctl 8
287.Sh AUTHORS
288The
289.Nm
290was written by
291.An Internet Initiative Japan Inc.
292