void xfrm_state_info_print(struct xfrm_usersa_info *xsinfo, struct rtattr *tb[], FILE *fp, const char *prefix, const char *title) { char buf[STRBUF_SIZE]; int force_spi = xfrm_xfrmproto_is_ipsec(xsinfo->id.proto); memset(buf, '\0', sizeof(buf)); xfrm_id_info_print(&xsinfo->saddr, &xsinfo->id, xsinfo->mode, xsinfo->reqid, xsinfo->family, force_spi, fp, prefix, title); if (prefix) STRBUF_CAT(buf, prefix); STRBUF_CAT(buf, "\t"); fputs(buf, fp); fprintf(fp, "replay-window %u ", xsinfo->replay_window); if (show_stats > 0) fprintf(fp, "seq 0x%08u ", xsinfo->seq); if (show_stats > 0 || xsinfo->flags) { __u8 flags = xsinfo->flags; fprintf(fp, "flag "); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_NOECN, "noecn"); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_DECAP_DSCP, "decap-dscp"); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_NOPMTUDISC, "nopmtudisc"); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_WILDRECV, "wildrecv"); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_ICMP, "icmp"); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_AF_UNSPEC, "af-unspec"); if (flags) fprintf(fp, "%x", flags); } if (show_stats > 0) fprintf(fp, " (0x%s)", strxf_mask8(xsinfo->flags)); fprintf(fp, "%s", _SL_); xfrm_xfrma_print(tb, xsinfo->family, fp, buf); if (!xfrm_selector_iszero(&xsinfo->sel)) { char sbuf[STRBUF_SIZE]; memcpy(sbuf, buf, sizeof(sbuf)); STRBUF_CAT(sbuf, "sel "); xfrm_selector_print(&xsinfo->sel, xsinfo->family, fp, sbuf); } if (show_stats > 0) { xfrm_lifetime_print(&xsinfo->lft, &xsinfo->curlft, fp, buf); xfrm_stats_print(&xsinfo->stats, fp, buf); } }
void xfrm_state_info_print(struct xfrm_usersa_info *xsinfo, struct rtattr *tb[], FILE *fp, const char *prefix, const char *title) { char buf[STRBUF_SIZE]; memset(buf, '\0', sizeof(buf)); xfrm_id_info_print(&xsinfo->saddr, &xsinfo->id, xsinfo->mode, xsinfo->reqid, xsinfo->family, 1, fp, prefix, title); if (prefix) STRBUF_CAT(buf, prefix); STRBUF_CAT(buf, "\t"); fprintf(fp, buf); fprintf(fp, "replay-window %u ", xsinfo->replay_window); if (show_stats > 0) fprintf(fp, "seq 0x%08u ", xsinfo->seq); if (show_stats > 0 || xsinfo->flags) { __u8 flags = xsinfo->flags; fprintf(fp, "flag "); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_NOECN, "noecn"); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_DECAP_DSCP, "decap-dscp"); if (flags) fprintf(fp, "%x", flags); if (show_stats > 0) fprintf(fp, " (0x%s)", strxf_mask8(flags)); } fprintf(fp, "%s", _SL_); xfrm_xfrma_print(tb, xsinfo->family, fp, buf); if (!xfrm_selector_iszero(&xsinfo->sel)) { char sbuf[STRBUF_SIZE]; memcpy(sbuf, buf, sizeof(sbuf)); STRBUF_CAT(sbuf, "sel "); xfrm_selector_print(&xsinfo->sel, xsinfo->family, fp, sbuf); } if (show_stats > 0) { xfrm_lifetime_print(&xsinfo->lft, &xsinfo->curlft, fp, buf); xfrm_stats_print(&xsinfo->stats, fp, buf); } }
static void xfrm_tmpl_print(struct xfrm_user_tmpl *tmpls, int len, __u16 family, FILE *fp, const char *prefix) { int ntmpls = len / sizeof(struct xfrm_user_tmpl); int i; if (ntmpls <= 0) { if (prefix) fputs(prefix, fp); fprintf(fp, "(ERROR \"tmpl\" truncated)"); fprintf(fp, "%s", _SL_); return; } for (i = 0; i < ntmpls; i++) { struct xfrm_user_tmpl *tmpl = &tmpls[i]; if (prefix) fputs(prefix, fp); xfrm_id_info_print(&tmpl->saddr, &tmpl->id, tmpl->mode, tmpl->reqid, tmpl->family, 0, fp, prefix, "tmpl "); if (show_stats > 0 || tmpl->optional) { if (prefix) fputs(prefix, fp); fprintf(fp, "\t"); switch (tmpl->optional) { case 0: if (show_stats > 0) fprintf(fp, "level required "); break; case 1: fprintf(fp, "level use "); break; default: fprintf(fp, "level %u ", tmpl->optional); break; } if (show_stats > 0) fprintf(fp, "share %s ", strxf_share(tmpl->share)); fprintf(fp, "%s", _SL_); } if (show_stats > 0) { if (prefix) fputs(prefix, fp); fprintf(fp, "\t"); fprintf(fp, "%s-mask %s ", strxf_algotype(XFRMA_ALG_CRYPT), strxf_mask32(tmpl->ealgos)); fprintf(fp, "%s-mask %s ", strxf_algotype(XFRMA_ALG_AUTH), strxf_mask32(tmpl->aalgos)); fprintf(fp, "%s-mask %s", strxf_algotype(XFRMA_ALG_COMP), strxf_mask32(tmpl->calgos)); fprintf(fp, "%s", _SL_); } } }
void xfrm_state_info_print(struct xfrm_usersa_info *xsinfo, struct rtattr *tb[], FILE *fp, const char *prefix, const char *title) { char buf[STRBUF_SIZE]; int force_spi = xfrm_xfrmproto_is_ipsec(xsinfo->id.proto); memset(buf, '\0', sizeof(buf)); xfrm_id_info_print(&xsinfo->saddr, &xsinfo->id, xsinfo->mode, xsinfo->reqid, xsinfo->family, force_spi, fp, prefix, title); if (prefix) STRBUF_CAT(buf, prefix); STRBUF_CAT(buf, "\t"); fputs(buf, fp); fprintf(fp, "replay-window %u ", xsinfo->replay_window); if (show_stats > 0) fprintf(fp, "seq 0x%08u ", xsinfo->seq); if (show_stats > 0 || xsinfo->flags) { __u8 flags = xsinfo->flags; fprintf(fp, "flag "); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_NOECN, "noecn"); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_DECAP_DSCP, "decap-dscp"); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_NOPMTUDISC, "nopmtudisc"); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_WILDRECV, "wildrecv"); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_ICMP, "icmp"); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_AF_UNSPEC, "af-unspec"); XFRM_FLAG_PRINT(fp, flags, XFRM_STATE_ALIGN4, "align4"); if (flags) fprintf(fp, "%x", flags); } if (show_stats > 0 && tb[XFRMA_SA_EXTRA_FLAGS]) { __u32 extra_flags = *(__u32 *)RTA_DATA(tb[XFRMA_SA_EXTRA_FLAGS]); fprintf(fp, "extra_flag "); XFRM_FLAG_PRINT(fp, extra_flags, XFRM_SA_XFLAG_DONT_ENCAP_DSCP, "dont-encap-dscp"); if (extra_flags) fprintf(fp, "%x", extra_flags); } if (show_stats > 0) fprintf(fp, " (0x%s)", strxf_mask8(xsinfo->flags)); fprintf(fp, "%s", _SL_); xfrm_xfrma_print(tb, xsinfo->family, fp, buf); if (!xfrm_selector_iszero(&xsinfo->sel)) { char sbuf[STRBUF_SIZE]; memcpy(sbuf, buf, sizeof(sbuf)); STRBUF_CAT(sbuf, "sel "); xfrm_selector_print(&xsinfo->sel, xsinfo->family, fp, sbuf); } if (show_stats > 0) { xfrm_lifetime_print(&xsinfo->lft, &xsinfo->curlft, fp, buf); xfrm_stats_print(&xsinfo->stats, fp, buf); } if (tb[XFRMA_SEC_CTX]) { struct xfrm_user_sec_ctx *sctx; fprintf(fp, "\tsecurity context "); if (RTA_PAYLOAD(tb[XFRMA_SEC_CTX]) < sizeof(*sctx)) fprintf(fp, "(ERROR truncated)"); sctx = (struct xfrm_user_sec_ctx *)RTA_DATA(tb[XFRMA_SEC_CTX]); fprintf(fp, "%s %s", (char *)(sctx + 1), _SL_); } }