+getsainfo_by_dst_id(const vchar_t *dst, const vchar_t *peer)
+{
+ struct sainfo *s = NULL;
+ struct sainfo *anonymous = NULL;
+
+ plog(ASL_LEVEL_DEBUG, "getsainfo_by_dst_id - dst id:\n");
+ if (dst != NULL)
+ plogdump(ASL_LEVEL_DEBUG, dst->v, dst->l, "getsainfo_by_dst_id - dst id:\n");
+ else
+ return NULL;
+
+ LIST_FOREACH(s, &sitree, chain) {
+ if (s->idsrc != NULL) {
+ plogdump(ASL_LEVEL_DEBUG, s->idsrc->v, s->idsrc->l, "getsainfo_by_dst_id - sainfo id - src:\n");
+ plogdump(ASL_LEVEL_DEBUG, s->iddst->v, s->iddst->l, "getsainfo_by_dst_id - sainfo id - dst:\n");
+ } else {
+ plog(ASL_LEVEL_DEBUG, "getsainfo_by_dst_id - sainfo id = anonymous\n");
+ }
+ if (s->id_i != NULL) {
+ plogdump(ASL_LEVEL_DEBUG, s->id_i->v, s->id_i->l, "getsainfo_by_dst_id - sainfo id_i:\n");
+ if (peer == NULL)
+ continue;
+ if (memcmp(peer->v, s->id_i->v, s->id_i->l) != 0)
+ continue;
+ }
+ if (s->idsrc == NULL) {
+ anonymous = s;
+ continue;
+ }
+
+ if (memcmp(dst->v, s->iddst->v, s->iddst->l) == 0)
+ return s;
+ }
+
+ if (anonymous) {
+ plog(ASL_LEVEL_DEBUG,
+ "anonymous sainfo selected.\n");
+ }
+
+ return anonymous;
+}
+
+
+struct sainfo *
+create_sainfo()