xref: /dflybsd-src/usr.sbin/rtadvd/control.h (revision c17e6018cab90fba83aa80d4974cfbeb9a5e75ca)
1*c17e6018SMatthew Dillon /*-
2*c17e6018SMatthew Dillon  * Copyright (C) 2011 Hiroki Sato <hrs@FreeBSD.org>
3*c17e6018SMatthew Dillon  * All rights reserved.
4*c17e6018SMatthew Dillon  *
5*c17e6018SMatthew Dillon  * Redistribution and use in source and binary forms, with or without
6*c17e6018SMatthew Dillon  * modification, are permitted provided that the following conditions
7*c17e6018SMatthew Dillon  * are met:
8*c17e6018SMatthew Dillon  * 1. Redistributions of source code must retain the above copyright
9*c17e6018SMatthew Dillon  *    notice, this list of conditions and the following disclaimer.
10*c17e6018SMatthew Dillon  * 2. Redistributions in binary form must reproduce the above copyright
11*c17e6018SMatthew Dillon  *    notice, this list of conditions and the following disclaimer in the
12*c17e6018SMatthew Dillon  *    documentation and/or other materials provided with the distribution.
13*c17e6018SMatthew Dillon  *
14*c17e6018SMatthew Dillon  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
15*c17e6018SMatthew Dillon  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*c17e6018SMatthew Dillon  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*c17e6018SMatthew Dillon  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
18*c17e6018SMatthew Dillon  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*c17e6018SMatthew Dillon  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*c17e6018SMatthew Dillon  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*c17e6018SMatthew Dillon  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*c17e6018SMatthew Dillon  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*c17e6018SMatthew Dillon  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*c17e6018SMatthew Dillon  * SUCH DAMAGE.
25*c17e6018SMatthew Dillon  *
26*c17e6018SMatthew Dillon  * $FreeBSD: stable/10/usr.sbin/rtadvd/control.h 225519 2011-09-12 23:52:55Z hrs $
27*c17e6018SMatthew Dillon  *
28*c17e6018SMatthew Dillon  */
29*c17e6018SMatthew Dillon 
30*c17e6018SMatthew Dillon #define	SOCK_BACKLOG		5
31*c17e6018SMatthew Dillon 
32*c17e6018SMatthew Dillon #define	CM_MSG_MAXLEN		8192
33*c17e6018SMatthew Dillon #define	CM_VERSION		1
34*c17e6018SMatthew Dillon #define	CM_VERSION_STR		"1.0"
35*c17e6018SMatthew Dillon 
36*c17e6018SMatthew Dillon #define	CM_TYPE_EOM		0
37*c17e6018SMatthew Dillon #define	CM_TYPE_ACK		1
38*c17e6018SMatthew Dillon #define	CM_TYPE_ERR		2
39*c17e6018SMatthew Dillon #define	CM_TYPE_NUL		3
40*c17e6018SMatthew Dillon #define	CM_TYPE_REQ_SET_PROP	4
41*c17e6018SMatthew Dillon #define	CM_TYPE_REQ_GET_PROP	5
42*c17e6018SMatthew Dillon #define	CM_TYPE_MAX		6
43*c17e6018SMatthew Dillon 
44*c17e6018SMatthew Dillon #define	CM_STATE_EOM		0
45*c17e6018SMatthew Dillon #define	CM_STATE_INIT		1
46*c17e6018SMatthew Dillon #define	CM_STATE_MSG_DISPATCH	2
47*c17e6018SMatthew Dillon #define	CM_STATE_MSG_RECV	3
48*c17e6018SMatthew Dillon #define	CM_STATE_ACK_WAIT	4
49*c17e6018SMatthew Dillon 
50*c17e6018SMatthew Dillon struct ctrl_msg_hdr {
51*c17e6018SMatthew Dillon 	int	cm_version;
52*c17e6018SMatthew Dillon 	size_t	cm_len;
53*c17e6018SMatthew Dillon 	int	cm_type;
54*c17e6018SMatthew Dillon };
55*c17e6018SMatthew Dillon 
56*c17e6018SMatthew Dillon struct ctrl_msg_pl {
57*c17e6018SMatthew Dillon 	char	*cp_ifname;
58*c17e6018SMatthew Dillon 	char	*cp_key;
59*c17e6018SMatthew Dillon 
60*c17e6018SMatthew Dillon 	size_t	cp_val_len;
61*c17e6018SMatthew Dillon 	char	*cp_val;
62*c17e6018SMatthew Dillon };
63*c17e6018SMatthew Dillon 
64*c17e6018SMatthew Dillon int	csock_open(struct sockinfo *, mode_t);
65*c17e6018SMatthew Dillon int	csock_close(struct sockinfo *);
66*c17e6018SMatthew Dillon int	csock_listen(struct sockinfo *);
67*c17e6018SMatthew Dillon int	csock_accept(struct sockinfo *);
68*c17e6018SMatthew Dillon int	cm_send(int, char *);
69*c17e6018SMatthew Dillon int	cm_recv(int, char *);
70*c17e6018SMatthew Dillon 
71*c17e6018SMatthew Dillon size_t			cm_pl2bin(char *, struct ctrl_msg_pl *);
72*c17e6018SMatthew Dillon struct ctrl_msg_pl	*cm_bin2pl(char *, struct ctrl_msg_pl *);
73*c17e6018SMatthew Dillon size_t			cm_str2bin(char *, void *, size_t);
74*c17e6018SMatthew Dillon void			*cm_bin2str(char *, void *, size_t);
75