MCPcopy Create free account
hub / github.com/F-Stack/f-stack / parse_hex_string

Function parse_hex_string

dpdk/examples/ip_pipeline/parser.c:260–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260int
261parse_hex_string(char *src, uint8_t *dst, uint32_t *size)
262{
263 char *c;
264 uint32_t len, i;
265
266 /* Check input parameters */
267 if ((src == NULL) ||
268 (dst == NULL) ||
269 (size == NULL) ||
270 (*size == 0))
271 return -1;
272
273 len = strlen(src);
274 if (((len & 3) != 0) ||
275 (len > (*size) * 2))
276 return -1;
277 *size = len / 2;
278
279 for (c = src; *c != 0; c++) {
280 if ((((*c) >= '0') && ((*c) <= '9')) ||
281 (((*c) >= 'A') && ((*c) <= 'F')) ||
282 (((*c) >= 'a') && ((*c) <= 'f')))
283 continue;
284
285 return -1;
286 }
287
288 /* Convert chars to bytes */
289 for (i = 0; i < *size; i++)
290 dst[i] = get_hex_val(src[2 * i]) * 16 +
291 get_hex_val(src[2 * i + 1]);
292
293 return 0;
294}
295
296int
297parse_mpls_labels(char *string, uint32_t *labels, uint32_t *n_labels)

Callers 7

cmd_table_action_profileFunction · 0.70
cmd_pipeline_tableFunction · 0.70
parse_matchFunction · 0.70
parse_table_action_aeadFunction · 0.70

Calls 1

get_hex_valFunction · 0.70

Tested by

no test coverage detected