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>
42 #include <System/net/pfkeyv2.h>
48 #if TIME_WITH_SYS_TIME
49 # include <sys/time.h>
53 # include <sys/time.h>
63 #include <sys/ioctl.h>
75 #include "racoonctl.h"
78 #include "isakmp_var.h"
80 #include "isakmp_xauth.h"
81 #include "isakmp_var.h"
82 #include "isakmp_cfg.h"
83 #include "isakmp_unity.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_func(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
);