/*
- * Copyright (C) 2010 Tobias Brunner
+ * Copyright (C) 2010-2019 Tobias Brunner
* Copyright (C) 2008 Martin Willi
* HSR Hochschule fuer Technik Rapperswil
*
enumerator_t public;
/** inner SQL enumerator */
enumerator_t *inner;
- /** own identity */
- identification_t *me;
- /** remote identity */
- identification_t *other;
+ /** own identity is defined */
+ bool me_defined;
+ /** remote identity is defined */
+ bool other_defined;
/** currently enumerated private key */
shared_key_t *current;
} shared_enumerator_t;
*shared = this->current;
if (me)
{
- *me = this->me ? ID_MATCH_PERFECT : ID_MATCH_ANY;
+ *me = this->me_defined ? ID_MATCH_PERFECT : ID_MATCH_ANY;
}
if (other)
{
- *other = this->other ? ID_MATCH_PERFECT : ID_MATCH_ANY;
+ *other = this->other_defined ? ID_MATCH_PERFECT : ID_MATCH_ANY;
}
return TRUE;
}
identification_t *me, identification_t *other)
{
shared_enumerator_t *e;
+ bool me_defined, other_defined;
+
+ me_defined = me && me->get_type(me) != ID_ANY;
+ other_defined = other && other->get_type(other) != ID_ANY;
INIT(e,
.public = {
.venumerate = _shared_enumerator_enumerate,
.destroy = _shared_enumerator_destroy,
},
- .me = me,
- .other = other,
+ .me_defined = me_defined,
+ .other_defined = other_defined,
);
- if (!me && !other)
+ if (!me_defined && !other_defined)
{
e->inner = this->db->query(this->db,
"SELECT s.type, s.data FROM shared_secrets AS s "
DB_INT, type == SHARED_ANY, DB_INT, type,
DB_INT, DB_BLOB);
}
- else if (me && other)
+ else if (me_defined && other_defined)
{
e->inner = this->db->query(this->db,
"SELECT s.type, s.data FROM shared_secrets AS s "
}
else
{
- identification_t *id = me ? me : other;
+ identification_t *id = me_defined ? me : other;
e->inner = this->db->query(this->db,
"SELECT s.type, s.data FROM shared_secrets AS s "
return &this->public;
}
-