xref: /openbsd-src/usr.sbin/npppd/npppd/npppd_ctl.h (revision e83549bea819e2aa287450bd2f098881308bb00c)
1 /*	$OpenBSD: npppd_ctl.h,v 1.7 2017/08/11 16:25:59 goda Exp $ */
2 
3 /*-
4  * Copyright (c) 2009 Internet Initiative Japan Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 #ifndef NPPPD_CTL_H
29 #define NPPPD_CTL_H 1
30 
31 #include <sys/types.h>
32 #include <sys/socket.h>		/* for <netinet/in.h> */
33 #include <net/if.h>		/* for IF_NAMESIZE */
34 #include <net/if_dl.h>		/* for sockaddr_dl */
35 #include <netinet/in.h>		/* for sockaddr_in{,6} and in_addr */
36 #include <imsg.h>		/* for imsg */
37 #include <time.h>		/* for time_t */
38 
39 #define	NPPPD_SOCKET			"/var/run/npppd.sock"
40 #define	NPPPD_CTL_USERNAME_SIZE		256
41 
42 enum imsg_type {
43 	IMSG_NONE,
44 	IMSG_CTL_OK,			/* answers to npppctl requests */
45 	IMSG_CTL_FAIL,
46 	IMSG_CTL_NOP,			/* npppctl requests */
47 	IMSG_CTL_WHO,
48 	IMSG_CTL_DISCONNECT,
49 	IMSG_CTL_MONITOR,
50 	IMSG_CTL_WHO_AND_MONITOR,
51 	IMSG_PPP_START,			/* notifies from npppd */
52 	IMSG_PPP_STOP
53 };
54 
55 struct npppd_who {
56 	u_int             ppp_id;	/** Ppp Id */
57 	char           	  username[NPPPD_CTL_USERNAME_SIZE];
58 					/** Username */
59 	time_t            time;		/** Start time */
60 	uint32_t          duration_sec;	/** Elapsed time */
61 	char              ifname[IF_NAMESIZE];
62 					/** Concentrated interface */
63 	char              rlmname[32];	/** Authenticated realm name */
64 	char              tunnel_proto[16];
65 					/** Tunnel protocol name */
66 	union {
67 		struct sockaddr_in  peer_in4;
68 		struct sockaddr_in6 peer_in6;
69 		struct sockaddr_dl  peer_dl;
70 	}                 tunnel_peer; 	/** Tunnel peer address */
71 	struct in_addr    framed_ip_address;
72 					/** Framed IP Address */
73 	uint16_t          mru;		/** MRU */
74 	uint32_t          ipackets;	/** Numbers of input packets */
75 	uint32_t          opackets;	/** Numbers of output packets */
76 	uint32_t          ierrors;	/** Numbers of input error packets */
77 	uint32_t          oerrors;	/** Numbers of output error packets */
78 	uint64_t          ibytes;	/** Bytes of input packets */
79 	uint64_t          obytes;	/** Bytes of output packets */
80 };
81 
82 struct npppd_who_list {
83 	int               more_data;	/** 1 if there is more data */
84 	int               entry_count;	/** count of the entry */
85 	struct npppd_who  entry[0];	/** entry arrays */
86 };
87 
88 struct npppd_disconnect_request {
89 	int               count;
90 	u_int             ppp_id[0];
91 } ;
92 
93 struct npppd_disconnect_response {
94 	int               count;
95 };
96 #endif
97