Parse pattern item parameter type. */
| 8174 | |
| 8175 | /** Parse pattern item parameter type. */ |
| 8176 | static int |
| 8177 | parse_vc_spec(struct context *ctx, const struct token *token, |
| 8178 | const char *str, unsigned int len, |
| 8179 | void *buf, unsigned int size) |
| 8180 | { |
| 8181 | struct buffer *out = buf; |
| 8182 | struct rte_flow_item *item; |
| 8183 | uint32_t data_size; |
| 8184 | int index; |
| 8185 | int objmask = 0; |
| 8186 | |
| 8187 | (void)size; |
| 8188 | /* Token name must match. */ |
| 8189 | if (parse_default(ctx, token, str, len, NULL, 0) < 0) |
| 8190 | return -1; |
| 8191 | /* Parse parameter types. */ |
| 8192 | switch (ctx->curr) { |
| 8193 | static const enum index prefix[] = NEXT_ENTRY(COMMON_PREFIX); |
| 8194 | |
| 8195 | case ITEM_PARAM_IS: |
| 8196 | index = 0; |
| 8197 | objmask = 1; |
| 8198 | break; |
| 8199 | case ITEM_PARAM_SPEC: |
| 8200 | index = 0; |
| 8201 | break; |
| 8202 | case ITEM_PARAM_LAST: |
| 8203 | index = 1; |
| 8204 | break; |
| 8205 | case ITEM_PARAM_PREFIX: |
| 8206 | /* Modify next token to expect a prefix. */ |
| 8207 | if (ctx->next_num < 2) |
| 8208 | return -1; |
| 8209 | ctx->next[ctx->next_num - 2] = prefix; |
| 8210 | /* Fall through. */ |
| 8211 | case ITEM_PARAM_MASK: |
| 8212 | index = 2; |
| 8213 | break; |
| 8214 | default: |
| 8215 | return -1; |
| 8216 | } |
| 8217 | /* Nothing else to do if there is no buffer. */ |
| 8218 | if (!out) |
| 8219 | return len; |
| 8220 | if (!out->args.vc.pattern_n) |
| 8221 | return -1; |
| 8222 | item = &out->args.vc.pattern[out->args.vc.pattern_n - 1]; |
| 8223 | data_size = ctx->objdata / 3; /* spec, last, mask */ |
| 8224 | /* Point to selected object. */ |
| 8225 | ctx->object = out->args.vc.data + (data_size * index); |
| 8226 | if (objmask) { |
| 8227 | ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */ |
| 8228 | item->mask = ctx->objmask; |
| 8229 | } else |
| 8230 | ctx->objmask = NULL; |
| 8231 | /* Update relevant item pointer. */ |
| 8232 | *((const void **[]){ &item->spec, &item->last, &item->mask })[index] = |
| 8233 | ctx->object; |
nothing calls this directly
no test coverage detected