1 /* $KAME: kmpstat.c,v 1.33 2004/08/16 08:20:28 itojun Exp $ */
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <sys/socket.h>
39 #include <netinet/in.h>
40 #include <arpa/inet.h>
43 #include <System/net/pfkeyv2.h>
45 #include <net/pfkeyv2.h>
52 #if TIME_WITH_SYS_TIME
53 # include <sys/time.h>
57 # include <sys/time.h>
67 #include <sys/ioctl.h>
79 #include "racoonctl.h"
82 #include "isakmp_var.h"
84 #include "isakmp_xauth.h"
85 #include "isakmp_var.h"
86 #include "isakmp_cfg.h"
87 #include "isakmp_unity.h"
93 #include "admin_var.h"
94 #include "ipsec_doi.h"
96 u_int32_t racoonctl_interface
= RACOONCTL_INTERFACE
;
97 u_int32_t racoonctl_interface_major
= RACOONCTL_INTERFACE_MAJOR
;
100 u_int32_t loglevel
= 0;
105 struct sockaddr_un name
;
107 memset(&name
, 0, sizeof(name
));
108 name
.sun_family
= AF_UNIX
;
109 snprintf(name
.sun_path
, sizeof(name
.sun_path
),
110 "%s", adminsock_path
);
112 so
= socket(AF_UNIX
, SOCK_STREAM
, 0);
116 if (connect(so
, (struct sockaddr
*)&name
, sizeof(name
)) < 0) {
130 if ((len
= send(so
, combuf
->v
, combuf
->l
, 0)) == -1) {
143 struct admin_com h
, *com
;
152 /* receive by PEEK */
153 if ((len
= recv(so
, &h
, sizeof(h
), MSG_PEEK
)) == -1)
165 /* allocate buffer */
166 if ((*combufp
= vmalloc(h
.ac_len
)) == NULL
)
169 /* read real message */
172 if ((len
= recv(so
, p
, h
.ac_len
, 0)) < 0) {
190 * Dumb plog functions (used by sockmisc.c)
193 plog(int pri
, const char *func
, struct sockaddr
*sa
, const char *fmt
, ...)
203 plogdump(pri
, data
, len
)
212 get_sockaddr(family
, name
, port
)
216 struct addrinfo hint
, *ai
;
219 memset(&hint
, 0, sizeof(hint
));
220 hint
.ai_family
= PF_UNSPEC
;
221 hint
.ai_family
= family
;
222 hint
.ai_socktype
= SOCK_STREAM
;
224 error
= getaddrinfo(name
, port
, &hint
, &ai
);
226 printf("%s: %s/%s\n", gai_strerror(error
), name
, port
);