parse_ct_state(const char *state_str, uint32_t default_state,
               uint32_t *ct_state, struct ds *ds)
{
    uint32_t state = default_state;
    char *state_s = xstrdup(state_str);
    char *save_ptr = NULL;

    for (char *cs = strtok_r(state_s, ", ", &save_ptr); cs;
         cs = strtok_r(NULL, ", ", &save_ptr)) {
        uint32_t bit = ct_state_from_string(cs);
        if (!bit) {
            ds_put_format(ds, "%s: unknown connection tracking state flag",
                          cs);
            free(state_s);
            return false;
        }
        state |= bit;
    }

    *ct_state = state;
    free(state_s);

    return true;
}
parse_ct_state(const char *state_str, uint32_t default_state,
               uint32_t *ct_state, struct ds *ds)
{
    uint32_t state = default_state;
    char *state_s = xstrdup(state_str);
    char *save_ptr = NULL;

    for (char *cs = strtok_r(state_s, ", ", &save_ptr); cs;
         cs = strtok_r(NULL, ", ", &save_ptr)) {
        uint32_t bit = ct_state_from_string(cs);
        if (!bit) {
            ds_put_format(ds, "%s: unknown connection tracking state flag",
                          cs);
            free(state_s);
            return false;
        }
        state |= bit;
    }

    *ct_state = state;
    free(state_s);

    return true;
}