1 /* $NetBSD: kmpstat.c,v 1.5 2007/05/30 21:02:40 manu Exp $ */
3 /* $KAME: kmpstat.c,v 1.33 2004/08/16 08:20:28 itojun Exp $ */
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include <sys/types.h>
37 #include <sys/param.h>
38 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <arpa/inet.h>
43 #include <net/pfkeyv2.h>
49 #if TIME_WITH_SYS_TIME
50 # include <sys/time.h>
54 # include <sys/time.h>
64 #include <sys/ioctl.h>
76 #include "racoonctl.h"
79 #include "isakmp_var.h"
81 #include "isakmp_xauth.h"
82 #include "isakmp_var.h"
83 #include "isakmp_cfg.h"
89 #include "admin_var.h"
90 #include "ipsec_doi.h"
92 u_int32_t racoonctl_interface
= RACOONCTL_INTERFACE
;
93 u_int32_t racoonctl_interface_major
= RACOONCTL_INTERFACE_MAJOR
;
96 u_int32_t loglevel
= 0;
101 struct sockaddr_un name
;
103 memset(&name
, 0, sizeof(name
));
104 name
.sun_family
= AF_UNIX
;
105 snprintf(name
.sun_path
, sizeof(name
.sun_path
),
106 "%s", adminsock_path
);
108 so
= socket(AF_UNIX
, SOCK_STREAM
, 0);
112 if (connect(so
, (struct sockaddr
*)&name
, sizeof(name
)) < 0) {
126 if ((len
= send(so
, combuf
->v
, combuf
->l
, 0)) == -1) {
139 struct admin_com h
, *com
;
148 /* receive by PEEK */
149 if ((len
= recv(so
, &h
, sizeof(h
), MSG_PEEK
)) == -1)
161 /* allocate buffer */
162 if ((*combufp
= vmalloc(h
.ac_len
)) == NULL
)
165 /* read real message */
168 if ((len
= recv(so
, p
, h
.ac_len
, 0)) < 0) {
186 * Dumb plog functions (used by sockmisc.c)
189 _plog(int pri
, const char *func
, struct sockaddr
*sa
, const char *fmt
, ...)
199 plogdump(pri
, data
, len
)
208 get_sockaddr(family
, name
, port
)
212 struct addrinfo hint
, *ai
;
215 memset(&hint
, 0, sizeof(hint
));
216 hint
.ai_family
= PF_UNSPEC
;
217 hint
.ai_family
= family
;
218 hint
.ai_socktype
= SOCK_STREAM
;
220 error
= getaddrinfo(name
, port
, &hint
, &ai
);
222 printf("%s: %s/%s\n", gai_strerror(error
), name
, port
);