2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

util: Add function hexits_value() for parsing multiple hex digits.

Suggested-by: Justin Pettit <jpettit@nicira.com>
This commit is contained in:
Ben Pfaff
2010-11-15 10:18:10 -08:00
parent 96fc46e8fd
commit bf9712678f
8 changed files with 84 additions and 44 deletions

View File

@@ -289,8 +289,8 @@ str_to_action(char *str, struct ofpbuf *b)
b->size -= sizeof nan->note;
while (arg && *arg != '\0') {
int high, low;
uint8_t byte;
bool ok;
if (*arg == '.') {
arg++;
@@ -299,16 +299,13 @@ str_to_action(char *str, struct ofpbuf *b)
break;
}
high = hexit_value(*arg++);
if (high >= 0) {
low = hexit_value(*arg++);
}
if (high < 0 || low < 0) {
byte = hexits_value(arg, 2, &ok);
if (!ok) {
ovs_fatal(0, "bad hex digit in `note' argument");
}
byte = high * 16 + low;
ofpbuf_put(b, &byte, 1);
arg += 2;
}
len = b->size - start_ofs;