Add support for getting table ranges Fixup get by key formatting while at it

This commit is contained in:
Jamal Hadi Salim 2013-07-15 18:28:36 -04:00 committed by Michael Richardson
parent 93e641bdc0
commit ec92c2539f
2 changed files with 68 additions and 1 deletions

View File

@ -295,6 +295,7 @@ struct pathdata_h {
#define B_SPARD 0x2
#define B_RESTV 0x4
#define B_KEYIN 0x8
#define B_TRNG 0x20
static const struct optlv_h OPTLV_msg[F_OP_MAX + 1] = {
/* F_OP_RSV */ {ZERO_TTLV, 0, "Invalid OPTLV", invoptlv_print},
@ -379,6 +380,9 @@ static inline int op_valid(u_int16_t op, u_int16_t mask)
#define F_TLV_REST 0x0114
#define F_TLV_METD 0x0115
#define F_TLV_REDD 0x0116
#define F_TLV_TRNG 0x0117
#define F_TLV_VNST 0x8000
static const struct tok ForCES_TLV[] = {
@ -592,6 +596,7 @@ int pdata_print(register const u_char * pptr, register u_int len,
int prestlv_print(register const u_char * pptr, register u_int len,
u_int16_t op_msk, int indent);
#define F_SELKEY 1
#define F_SELTABRANGE 2
struct res_val {
u_int8_t result;

View File

@ -212,6 +212,8 @@ trunc:
return -1;
}
#define PTH_DESC_SIZE 12
int
pdatacnt_print(register const u_char * pptr, register u_int len,
u_int16_t IDcnt, u_int16_t op_msk, int indent)
@ -226,10 +228,58 @@ pdatacnt_print(register const u_char * pptr, register u_int len,
goto trunc;
id = EXTRACT_32BITS(pptr);
if (vflag >= 3)
printf("%s ID#%02u: %d\n", ib, i + 1, id);
printf("%sID#%02u: %d\n", ib, i + 1, id);
len -= 4;
pptr += 4;
}
if ((op_msk & B_TRNG) || (op_msk & B_KEYIN)) {
if (len < PTH_DESC_SIZE) {
printf("pathlength %d with key/range too short %d\n",
len, PTH_DESC_SIZE);
return -1;
}
if (op_msk & B_TRNG) {
u_int32_t starti, endi;
pptr += sizeof(struct forces_tlv);
len -= sizeof(struct forces_tlv);
starti = EXTRACT_32BITS(pptr);
pptr += 4;
len -= 4;
endi = EXTRACT_32BITS(pptr);
pptr += 4;
len -= 4;
if (vflag >= 3)
printf("%sTable range: [%d,%d]\n", ib, starti, endi);
}
if (op_msk & B_KEYIN) {
struct forces_tlv *keytlv;
u_int16_t tll;
u_int32_t keyid = EXTRACT_32BITS(pptr);
/* skip keyid */
pptr += 4;
len -= 4;
keytlv = (struct forces_tlv *)pptr;
/* skip header */
pptr += sizeof(struct forces_tlv);
len -= sizeof(struct forces_tlv);
/* skip key content */
tll = EXTRACT_16BITS(&keytlv->length) - TLV_HDRL;
pptr += tll;
len -= tll;
if (len < 0) {
printf("Key content too short\n");
return -1;
}
}
}
if (len) {
const struct forces_tlv *pdtlv = (struct forces_tlv *)pptr;
u_int16_t type;
@ -328,6 +378,12 @@ pdata_print(register const u_char * pptr, register u_int len,
if (EXTRACT_16BITS(&pdh->pflags) & F_SELKEY) {
op_msk |= B_KEYIN;
}
/* Table GET Range operation */
if (EXTRACT_16BITS(&pdh->pflags) & F_SELTABRANGE) {
op_msk |= B_TRNG;
}
pptr += sizeof(struct pathdata_h);
len -= sizeof(struct pathdata_h);
idcnt = EXTRACT_16BITS(&pdh->pIDcnt);
@ -339,6 +395,12 @@ pdata_print(register const u_char * pptr, register u_int len,
printf("]\n");
return -1;
}
if ((op_msk & B_TRNG) && (op_msk & B_KEYIN)) {
printf("\t\t\tIllegal to have both Table ranges and keys\n");
return -1;
}
more_pd = pdatacnt_print(pptr, len, idcnt, op_msk, indent);
if (more_pd > 0) {
int consumed = len - more_pd;