X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fflow.c;fp=lib%2Fflow.c;h=57eddba26776eadc4aca0a0f9e280937c9823c04;hb=4fe3445afbbcda01e426d26cdcc1c7daa5d9f823;hp=3085848dc37686396f3e964985ab3e494c1156bd;hpb=72e8bf28bb38e8816435c64859fb350215b6a9e6;p=openvswitch diff --git a/lib/flow.c b/lib/flow.c index 3085848d..57eddba2 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -479,6 +479,50 @@ flow_to_string(const struct flow *flow) return ds_cstr(&ds); } +const char * +flow_tun_flag_to_string(uint32_t flags) +{ + switch (flags) { + case FLOW_TNL_F_DONT_FRAGMENT: + return "df"; + case FLOW_TNL_F_CSUM: + return "csum"; + case FLOW_TNL_F_KEY: + return "key"; + default: + return NULL; + } +} + +void +format_flags(struct ds *ds, const char *(*bit_to_string)(uint32_t), + uint32_t flags, char del) +{ + uint32_t bad = 0; + + if (!flags) { + return; + } + while (flags) { + uint32_t bit = rightmost_1bit(flags); + const char *s; + + s = bit_to_string(bit); + if (s) { + ds_put_format(ds, "%s%c", s, del); + } else { + bad |= bit; + } + + flags &= ~bit; + } + + if (bad) { + ds_put_format(ds, "0x%"PRIx32"%c", bad, del); + } + ds_chomp(ds, del); +} + void flow_format(struct ds *ds, const struct flow *flow) {