Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libipsec/pfkey_dump.c
Show First 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | pfkey_sadump(m) | ||||
caddr_t mhp[SADB_EXT_MAX + 1]; | caddr_t mhp[SADB_EXT_MAX + 1]; | ||||
struct sadb_sa *m_sa; | struct sadb_sa *m_sa; | ||||
struct sadb_x_sa2 *m_sa2; | struct sadb_x_sa2 *m_sa2; | ||||
struct sadb_lifetime *m_lftc, *m_lfth, *m_lfts; | struct sadb_lifetime *m_lftc, *m_lfth, *m_lfts; | ||||
struct sadb_address *m_saddr, *m_daddr, *m_paddr; | struct sadb_address *m_saddr, *m_daddr, *m_paddr; | ||||
struct sadb_key *m_auth, *m_enc; | struct sadb_key *m_auth, *m_enc; | ||||
struct sadb_ident *m_sid, *m_did; | struct sadb_ident *m_sid, *m_did; | ||||
struct sadb_sens *m_sens; | struct sadb_sens *m_sens; | ||||
struct sadb_x_sa_replay *m_sa_replay; | |||||
/* check pfkey message. */ | /* check pfkey message. */ | ||||
if (pfkey_align(m, mhp)) { | if (pfkey_align(m, mhp)) { | ||||
printf("%s\n", ipsec_strerror()); | printf("%s\n", ipsec_strerror()); | ||||
return; | return; | ||||
} | } | ||||
if (pfkey_check(mhp)) { | if (pfkey_check(mhp)) { | ||||
printf("%s\n", ipsec_strerror()); | printf("%s\n", ipsec_strerror()); | ||||
return; | return; | ||||
} | } | ||||
m_sa = (struct sadb_sa *)mhp[SADB_EXT_SA]; | m_sa = (struct sadb_sa *)mhp[SADB_EXT_SA]; | ||||
m_sa2 = (struct sadb_x_sa2 *)mhp[SADB_X_EXT_SA2]; | m_sa2 = (struct sadb_x_sa2 *)mhp[SADB_X_EXT_SA2]; | ||||
m_lftc = (struct sadb_lifetime *)mhp[SADB_EXT_LIFETIME_CURRENT]; | m_lftc = (struct sadb_lifetime *)mhp[SADB_EXT_LIFETIME_CURRENT]; | ||||
m_lfth = (struct sadb_lifetime *)mhp[SADB_EXT_LIFETIME_HARD]; | m_lfth = (struct sadb_lifetime *)mhp[SADB_EXT_LIFETIME_HARD]; | ||||
m_lfts = (struct sadb_lifetime *)mhp[SADB_EXT_LIFETIME_SOFT]; | m_lfts = (struct sadb_lifetime *)mhp[SADB_EXT_LIFETIME_SOFT]; | ||||
m_saddr = (struct sadb_address *)mhp[SADB_EXT_ADDRESS_SRC]; | m_saddr = (struct sadb_address *)mhp[SADB_EXT_ADDRESS_SRC]; | ||||
m_daddr = (struct sadb_address *)mhp[SADB_EXT_ADDRESS_DST]; | m_daddr = (struct sadb_address *)mhp[SADB_EXT_ADDRESS_DST]; | ||||
m_paddr = (struct sadb_address *)mhp[SADB_EXT_ADDRESS_PROXY]; | m_paddr = (struct sadb_address *)mhp[SADB_EXT_ADDRESS_PROXY]; | ||||
m_auth = (struct sadb_key *)mhp[SADB_EXT_KEY_AUTH]; | m_auth = (struct sadb_key *)mhp[SADB_EXT_KEY_AUTH]; | ||||
m_enc = (struct sadb_key *)mhp[SADB_EXT_KEY_ENCRYPT]; | m_enc = (struct sadb_key *)mhp[SADB_EXT_KEY_ENCRYPT]; | ||||
m_sid = (struct sadb_ident *)mhp[SADB_EXT_IDENTITY_SRC]; | m_sid = (struct sadb_ident *)mhp[SADB_EXT_IDENTITY_SRC]; | ||||
m_did = (struct sadb_ident *)mhp[SADB_EXT_IDENTITY_DST]; | m_did = (struct sadb_ident *)mhp[SADB_EXT_IDENTITY_DST]; | ||||
m_sens = (struct sadb_sens *)mhp[SADB_EXT_SENSITIVITY]; | m_sens = (struct sadb_sens *)mhp[SADB_EXT_SENSITIVITY]; | ||||
m_sa_replay = (struct sadb_x_sa_replay *)mhp[SADB_X_EXT_SA_REPLAY]; | |||||
/* source address */ | /* source address */ | ||||
if (m_saddr == NULL) { | if (m_saddr == NULL) { | ||||
printf("no ADDRESS_SRC extension.\n"); | printf("no ADDRESS_SRC extension.\n"); | ||||
return; | return; | ||||
} | } | ||||
printf("%s ", str_ipaddr((struct sockaddr *)(m_saddr + 1))); | printf("%s ", str_ipaddr((struct sockaddr *)(m_saddr + 1))); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if (m_auth != NULL) { | ||||
ipsec_hexdump((caddr_t)m_auth + sizeof(*m_auth), | ipsec_hexdump((caddr_t)m_auth + sizeof(*m_auth), | ||||
m_auth->sadb_key_bits / 8); | m_auth->sadb_key_bits / 8); | ||||
printf("\n"); | printf("\n"); | ||||
} | } | ||||
/* replay windoe size & flags */ | /* replay windoe size & flags */ | ||||
printf("\tseq=0x%08x replay=%u flags=0x%08x ", | printf("\tseq=0x%08x replay=%u flags=0x%08x ", | ||||
m_sa2->sadb_x_sa2_sequence, | m_sa2->sadb_x_sa2_sequence, | ||||
m_sa_replay ? (m_sa_replay->sadb_x_sa_replay_replay >> 3) : | |||||
m_sa->sadb_sa_replay, | m_sa->sadb_sa_replay, | ||||
m_sa->sadb_sa_flags); | m_sa->sadb_sa_flags); | ||||
/* state */ | /* state */ | ||||
printf("state="); | printf("state="); | ||||
GETMSGSTR(str_state, m_sa->sadb_sa_state); | GETMSGSTR(str_state, m_sa->sadb_sa_state); | ||||
printf("\n"); | printf("\n"); | ||||
/* lifetime */ | /* lifetime */ | ||||
▲ Show 20 Lines • Show All 320 Lines • Show Last 20 Lines |