validate_ct_state(uint32_t state, struct ds *ds)
{
    bool valid_ct_state = true;
    struct ds d_str = DS_EMPTY_INITIALIZER;

    format_flags(&d_str, ct_state_to_string, state, '|');

    if (state && !(state & CS_TRACKED)) {
        ds_put_format(ds, "%s: invalid connection state: "
                      "If \"trk\" is unset, no other flags are set\n",
                      ds_cstr(&d_str));
        valid_ct_state = false;
    }
    if (state & CS_INVALID && state & ~(CS_TRACKED | CS_INVALID)) {
        ds_put_format(ds, "%s: invalid connection state: "
                      "when \"inv\" is set, only \"trk\" may also be set\n",
                      ds_cstr(&d_str));
        valid_ct_state = false;
    }
    if (state & CS_NEW && state & CS_ESTABLISHED) {
        ds_put_format(ds, "%s: invalid connection state: "
                      "\"new\" and \"est\" are mutually exclusive\n",
                      ds_cstr(&d_str));
        valid_ct_state = false;
    }
    if (state & CS_NEW && state & CS_REPLY_DIR) {
        ds_put_format(ds, "%s: invalid connection state: "
                      "\"new\" and \"rpy\" are mutually exclusive\n",
                      ds_cstr(&d_str));
        valid_ct_state = false;
    }

    ds_destroy(&d_str);
    return valid_ct_state;
}
validate_ct_state(uint32_t state, struct ds *ds)
{
    bool valid_ct_state = true;
    struct ds d_str = DS_EMPTY_INITIALIZER;

    format_flags(&d_str, ct_state_to_string, state, '|');

    if (state && !(state & CS_TRACKED)) {
        ds_put_format(ds, "%s: invalid connection state: "
                      "If \"trk\" is unset, no other flags are set\n",
                      ds_cstr(&d_str));
        valid_ct_state = false;
    }
    if (state & CS_INVALID && state & ~(CS_TRACKED | CS_INVALID)) {
        ds_put_format(ds, "%s: invalid connection state: "
                      "when \"inv\" is set, only \"trk\" may also be set\n",
                      ds_cstr(&d_str));
        valid_ct_state = false;
    }
    if (state & CS_NEW && state & CS_ESTABLISHED) {
        ds_put_format(ds, "%s: invalid connection state: "
                      "\"new\" and \"est\" are mutually exclusive\n",
                      ds_cstr(&d_str));
        valid_ct_state = false;
    }
    if (state & CS_NEW && state & CS_REPLY_DIR) {
        ds_put_format(ds, "%s: invalid connection state: "
                      "\"new\" and \"rpy\" are mutually exclusive\n",
                      ds_cstr(&d_str));
        valid_ct_state = false;
    }

    ds_destroy(&d_str);
    return valid_ct_state;
}