Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libipsec/pfkey_dump.c
Show All 29 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <netipsec/ipsec.h> | #include <net/if.h> | ||||
#include <net/pfkeyv2.h> | #include <net/pfkeyv2.h> | ||||
#include <netipsec/ipsec.h> | |||||
#include <netipsec/key_var.h> | #include <netipsec/key_var.h> | ||||
#include <netipsec/key_debug.h> | #include <netipsec/key_debug.h> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <arpa/inet.h> | #include <arpa/inet.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | |||||
static struct val2str str_alg_comp[] = { | static struct val2str str_alg_comp[] = { | ||||
{ SADB_X_CALG_NONE, "none", }, | { SADB_X_CALG_NONE, "none", }, | ||||
{ SADB_X_CALG_OUI, "oui", }, | { SADB_X_CALG_OUI, "oui", }, | ||||
{ SADB_X_CALG_DEFLATE, "deflate", }, | { SADB_X_CALG_DEFLATE, "deflate", }, | ||||
{ SADB_X_CALG_LZS, "lzs", }, | { SADB_X_CALG_LZS, "lzs", }, | ||||
{ -1, NULL, }, | { -1, NULL, }, | ||||
}; | }; | ||||
static struct val2str str_sp_scope[] = { | |||||
{ IPSEC_POLICYSCOPE_GLOBAL, "global" }, | |||||
{ IPSEC_POLICYSCOPE_IFNET, "ifnet" }, | |||||
{ IPSEC_POLICYSCOPE_PCB, "pcb"}, | |||||
{ -1, NULL }, | |||||
}; | |||||
/* | /* | ||||
* dump SADB_MSG formated. For debugging, you should use kdebug_sadb(). | * dump SADB_MSG formated. For debugging, you should use kdebug_sadb(). | ||||
*/ | */ | ||||
void | void | ||||
pfkey_sadump(m) | pfkey_sadump(m) | ||||
struct sadb_msg *m; | struct sadb_msg *m; | ||||
{ | { | ||||
caddr_t mhp[SADB_EXT_MAX + 1]; | caddr_t mhp[SADB_EXT_MAX + 1]; | ||||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | pfkey_sadump(m) | ||||
/* XXX DEBUG */ | /* XXX DEBUG */ | ||||
printf("refcnt=%u\n", m->sadb_msg_reserved); | printf("refcnt=%u\n", m->sadb_msg_reserved); | ||||
return; | return; | ||||
} | } | ||||
void | void | ||||
pfkey_spdump(m) | pfkey_spdump(struct sadb_msg *m) | ||||
struct sadb_msg *m; | |||||
{ | { | ||||
char pbuf[NI_MAXSERV]; | char pbuf[NI_MAXSERV]; | ||||
caddr_t mhp[SADB_EXT_MAX + 1]; | caddr_t mhp[SADB_EXT_MAX + 1]; | ||||
struct sadb_address *m_saddr, *m_daddr; | struct sadb_address *m_saddr, *m_daddr; | ||||
struct sadb_x_policy *m_xpl; | struct sadb_x_policy *m_xpl; | ||||
struct sadb_lifetime *m_lftc = NULL, *m_lfth = NULL; | struct sadb_lifetime *m_lftc = NULL, *m_lfth = NULL; | ||||
struct sockaddr *sa; | struct sockaddr *sa; | ||||
u_int16_t sport = 0, dport = 0; | u_int16_t sport = 0, dport = 0; | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | pfkey_spdump(struct sadb_msg *m) | ||||
if (m_lfth) { | if (m_lfth) { | ||||
printf("\tlifetime: %lu(s) ", | printf("\tlifetime: %lu(s) ", | ||||
(u_long)m_lfth->sadb_lifetime_addtime); | (u_long)m_lfth->sadb_lifetime_addtime); | ||||
printf("validtime: %lu(s)\n", | printf("validtime: %lu(s)\n", | ||||
(u_long)m_lfth->sadb_lifetime_usetime); | (u_long)m_lfth->sadb_lifetime_usetime); | ||||
} | } | ||||
printf("\tspid=%ld seq=%ld pid=%ld\n", | printf("\tspid=%ld seq=%ld pid=%ld scope=", | ||||
(u_long)m_xpl->sadb_x_policy_id, | (u_long)m_xpl->sadb_x_policy_id, | ||||
(u_long)m->sadb_msg_seq, | (u_long)m->sadb_msg_seq, | ||||
(u_long)m->sadb_msg_pid); | (u_long)m->sadb_msg_pid); | ||||
GETMSGV2S(str_sp_scope, m_xpl->sadb_x_policy_scope); | |||||
if (m_xpl->sadb_x_policy_scope == IPSEC_POLICYSCOPE_IFNET && | |||||
if_indextoname(m_xpl->sadb_x_policy_ifindex, pbuf) != NULL) | |||||
printf("ifname=%s", pbuf); | |||||
printf("\n"); | |||||
/* XXX TEST */ | /* XXX TEST */ | ||||
printf("\trefcnt=%u\n", m->sadb_msg_reserved); | printf("\trefcnt=%u\n", m->sadb_msg_reserved); | ||||
return; | return; | ||||
} | } | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 147 Lines • Show Last 20 Lines |