* Parse a MAC address. * * Last argument (ctx->args) is retrieved to determine storage size and * location. */
| 11074 | * location. |
| 11075 | */ |
| 11076 | static int |
| 11077 | parse_mac_addr(struct context *ctx, const struct token *token, |
| 11078 | const char *str, unsigned int len, |
| 11079 | void *buf, unsigned int size) |
| 11080 | { |
| 11081 | const struct arg *arg = pop_args(ctx); |
| 11082 | struct rte_ether_addr tmp; |
| 11083 | int ret; |
| 11084 | |
| 11085 | (void)token; |
| 11086 | /* Argument is expected. */ |
| 11087 | if (!arg) |
| 11088 | return -1; |
| 11089 | size = arg->size; |
| 11090 | /* Bit-mask fill is not supported. */ |
| 11091 | if (arg->mask || size != sizeof(tmp)) |
| 11092 | goto error; |
| 11093 | /* Only network endian is supported. */ |
| 11094 | if (!arg->hton) |
| 11095 | goto error; |
| 11096 | ret = cmdline_parse_etheraddr(NULL, str, &tmp, size); |
| 11097 | if (ret < 0 || (unsigned int)ret != len) |
| 11098 | goto error; |
| 11099 | if (!ctx->object) |
| 11100 | return len; |
| 11101 | buf = (uint8_t *)ctx->object + arg->offset; |
| 11102 | memcpy(buf, &tmp, size); |
| 11103 | if (ctx->objmask) |
| 11104 | memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size); |
| 11105 | return len; |
| 11106 | error: |
| 11107 | push_args(ctx, arg); |
| 11108 | return -1; |
| 11109 | } |
| 11110 | |
| 11111 | /** |
| 11112 | * Parse an IPv4 address. |
nothing calls this directly
no test coverage detected