Commit bcf32819 authored by 12!tgraf's avatar 12!tgraf

Use tb[type] access to TLVs

(Logical change 1.129)
parent 2534613e
...@@ -565,25 +565,28 @@ static void xfrm_tmpl_print(struct xfrm_user_tmpl *tmpls, int len, ...@@ -565,25 +565,28 @@ static void xfrm_tmpl_print(struct xfrm_user_tmpl *tmpls, int len,
} }
} }
void xfrm_xfrma_print(struct rtattr *tb[], int ntb, __u16 family, void xfrm_xfrma_print(struct rtattr *tb[], __u16 family,
FILE *fp, const char *prefix) FILE *fp, const char *prefix)
{ {
int i; if (tb[XFRMA_ALG_AUTH]) {
struct rtattr *rta = tb[XFRMA_ALG_AUTH];
xfrm_algo_print((struct xfrm_algo *) RTA_DATA(rta),
XFRMA_ALG_AUTH, RTA_PAYLOAD(rta), fp, prefix);
}
for (i = 0; i < ntb; i++) { if (tb[XFRMA_ALG_CRYPT]) {
__u16 type = tb[i]->rta_type; struct rtattr *rta = tb[XFRMA_ALG_CRYPT];
int len = RTA_PAYLOAD(tb[i]); xfrm_algo_print((struct xfrm_algo *) RTA_DATA(rta),
void *data = RTA_DATA(tb[i]); XFRMA_ALG_CRYPT, RTA_PAYLOAD(rta), fp, prefix);
}
switch (type) {
case XFRMA_ALG_CRYPT: if (tb[XFRMA_ALG_COMP]) {
case XFRMA_ALG_AUTH: struct rtattr *rta = tb[XFRMA_ALG_COMP];
case XFRMA_ALG_COMP: xfrm_algo_print((struct xfrm_algo *) RTA_DATA(rta),
xfrm_algo_print((struct xfrm_algo *)data, type, len, XFRMA_ALG_COMP, RTA_PAYLOAD(rta), fp, prefix);
fp, prefix); }
break;
case XFRMA_ENCAP: if (tb[XFRMA_ENCAP]) {
{
struct xfrm_encap_tmpl *e; struct xfrm_encap_tmpl *e;
char abuf[256]; char abuf[256];
...@@ -591,12 +594,12 @@ void xfrm_xfrma_print(struct rtattr *tb[], int ntb, __u16 family, ...@@ -591,12 +594,12 @@ void xfrm_xfrma_print(struct rtattr *tb[], int ntb, __u16 family,
fprintf(fp, prefix); fprintf(fp, prefix);
fprintf(fp, "encap "); fprintf(fp, "encap ");
if (len < sizeof(*e)) { if (RTA_PAYLOAD(tb[XFRMA_ENCAP]) < sizeof(*e)) {
fprintf(fp, "(ERROR truncated)"); fprintf(fp, "(ERROR truncated)");
fprintf(fp, "%s", _SL_); fprintf(fp, "%s", _SL_);
break; return;
} }
e = (struct xfrm_encap_tmpl *)data; e = (struct xfrm_encap_tmpl *) RTA_DATA(tb[XFRMA_ENCAP]);
fprintf(fp, "type %u ", e->encap_type); fprintf(fp, "type %u ", e->encap_type);
fprintf(fp, "sport %u ", ntohs(e->encap_sport)); fprintf(fp, "sport %u ", ntohs(e->encap_sport));
...@@ -607,19 +610,12 @@ void xfrm_xfrma_print(struct rtattr *tb[], int ntb, __u16 family, ...@@ -607,19 +610,12 @@ void xfrm_xfrma_print(struct rtattr *tb[], int ntb, __u16 family,
rt_addr_n2a(family, sizeof(e->encap_oa), rt_addr_n2a(family, sizeof(e->encap_oa),
&e->encap_oa, abuf, sizeof(abuf))); &e->encap_oa, abuf, sizeof(abuf)));
fprintf(fp, "%s", _SL_); fprintf(fp, "%s", _SL_);
break;
}
case XFRMA_TMPL:
xfrm_tmpl_print((struct xfrm_user_tmpl *)data,
len, family, fp, prefix);
break;
default:
if (prefix)
fprintf(fp, prefix);
fprintf(fp, "%u (unknown rta_type)", type);
fprintf(fp, "%s", _SL_);
break;
} }
if (tb[XFRMA_TMPL]) {
struct rtattr *rta = tb[XFRMA_TMPL];
xfrm_tmpl_print((struct xfrm_user_tmpl *) RTA_DATA(rta),
RTA_PAYLOAD(rta), family, fp, prefix);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment