- Compilation again. Now we have the sufficient components, and can

start to reconnect.
This commit is contained in:
ccremers 2004-08-18 09:57:01 +00:00
parent b2838ed1e4
commit eb5a39522b
2 changed files with 90 additions and 102 deletions

View File

@ -169,7 +169,7 @@ add_read_goals (const int run, int old, int new)
sys->runs[run].length = new; sys->runs[run].length = new;
i = old; i = old;
rd = roledef_shift (sys->runs[run], i); rd = roledef_shift (sys->runs[run].start, i);
while (i < new) while (i < new)
{ {
if (rd->type == READ) if (rd->type == READ)
@ -297,13 +297,13 @@ bind_existing_to_goal (const Binding b, const int index, const int run,
Roledef rd; Roledef rd;
int flag; int flag;
int old_length; int old_length;
int newgoals;
int subterm_iterate (Termlist substlist, Termlist keylist) int subterm_iterate (Termlist substlist, Termlist keylist)
{ {
int keycount; int keycount;
int flag; int flag;
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (5)) if (DEBUGL (5))
{ {
@ -319,17 +319,14 @@ bind_existing_to_goal (const Binding b, const int index, const int run,
{ {
int keyrun; int keyrun;
keyrun = create_intruder_goal (keylist->term); goal_add (keylist->term, b->run_to, b->ev_to);
if (!binding_add (keyrun, 0, goal.run, goal.index, keylist->term))
flag = 0;
keylist = keylist->next; keylist = keylist->next;
keycount++; keycount++;
} }
flag = flag && iterate (); flag = flag && iterate ();
while (keycount > 0) while (keycount > 0)
{ {
binding_remove_last (); goal_remove_last ();
roleInstanceDestroy (sys);
keycount--; keycount--;
} }
termlistDestroy (keylist); termlistDestroy (keylist);
@ -348,27 +345,32 @@ bind_existing_to_goal (const Binding b, const int index, const int run,
// Fix length // Fix length
old_length = sys->runs[run].length; old_length = sys->runs[run].length;
if ((index + 1) > old_length) if ((index + 1) > old_length)
sys->runs[run].length = index + 1; {
newgoals = add_read_goals (run, old_length, index+1);
}
else
{
newgoals = 0;
}
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (3)) if (DEBUGL (3))
{ {
explanation = "Bind existing run (generic) "; explanation = "Bind existing run (generic) ";
e_run = run; e_run = run;
e_term1 = goal.rd->message; e_term1 = b->term;
e_term2 = rd->message;
} }
#endif #endif
if (binding_add (run, index, goal.run, goal.index, goal.rd->message)) if (goal_bind (b, run, index))
{ {
if (subterm) if (subterm)
{ {
flag = termMguSubTerm (goal.rd->message, rd->message, flag = termMguSubTerm (b->term, rd->message,
subterm_iterate, sys->know->inverses, NULL); subterm_iterate, sys->know->inverses, NULL);
} }
else else
{ {
flag = termMguInTerm (goal.rd->message, rd->message, flag = termMguInTerm (b->term, rd->message,
interm_iterate); interm_iterate);
} }
} }
@ -382,15 +384,16 @@ bind_existing_to_goal (const Binding b, const int index, const int run,
} }
#endif #endif
} }
binding_remove_last (); goal_unbind (b);
// Reset length // Reset length
remove_read_goals (newgoals);
sys->runs[run].length = old_length; sys->runs[run].length = old_length;
return flag; return flag;
} }
//! Bind a goal to an existing regular run, if possible //! Bind a goal to an existing regular run, if possible
int int
bind_existing_run (const Goal goal, const Protocol p, const Role r, bind_existing_run (const Binding b, const Protocol p, const Role r,
const int index, const int subterm) const int index, const int subterm)
{ {
int run, flag; int run, flag;
@ -400,7 +403,7 @@ bind_existing_run (const Goal goal, const Protocol p, const Role r,
{ {
indentPrint (); indentPrint ();
eprintf ("Trying to bind "); eprintf ("Trying to bind ");
termPrint (goal.rd->message); termPrint (b->term);
eprintf (" to an existing instance of "); eprintf (" to an existing instance of ");
termPrint (p->nameterm); termPrint (p->nameterm);
eprintf (", "); eprintf (", ");
@ -413,7 +416,7 @@ bind_existing_run (const Goal goal, const Protocol p, const Role r,
{ {
if (sys->runs[run].protocol == p && sys->runs[run].role == r) if (sys->runs[run].protocol == p && sys->runs[run].role == r)
{ {
flag = flag && bind_existing_to_goal (goal, index, run, subterm); flag = flag && bind_existing_to_goal (b, index, run, subterm);
} }
} }
return flag; return flag;
@ -421,20 +424,22 @@ bind_existing_run (const Goal goal, const Protocol p, const Role r,
//! Bind a goal to a new run //! Bind a goal to a new run
int int
bind_new_run (const Goal goal, const Protocol p, const Role r, bind_new_run (const Binding b, const Protocol p, const Role r,
const int index, const int subterm) const int index, const int subterm)
{ {
int run; int run;
int flag; int flag;
int newgoals;
roleInstance (sys, p, r, NULL, NULL); roleInstance (sys, p, r, NULL, NULL);
run = sys->maxruns - 1; run = sys->maxruns - 1;
newgoals = add_read_goals (run, 0, index+1);
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (4)) if (DEBUGL (4))
{ {
indentPrint (); indentPrint ();
eprintf ("Trying to bind "); eprintf ("Trying to bind ");
termPrint (goal.rd->message); termPrint (b->term);
eprintf (" to a new instance of "); eprintf (" to a new instance of ");
termPrint (p->nameterm); termPrint (p->nameterm);
eprintf (", "); eprintf (", ");
@ -442,8 +447,9 @@ bind_new_run (const Goal goal, const Protocol p, const Role r,
eprintf (", run %i (subterm:%i)\n", run, subterm); eprintf (", run %i (subterm:%i)\n", run, subterm);
} }
#endif #endif
flag = bind_existing_to_goal (goal, index, run, subterm); flag = bind_existing_to_goal (b, index, run, subterm);
roleInstanceDestroy (sys); roleInstanceDestroy (sys);
remove_read_goals (newgoals);
return flag; return flag;
} }
@ -525,41 +531,32 @@ printSemiState ()
/** /**
* Should be ordered to prefer most constrained; for now, it is simply the first one encountered. * Should be ordered to prefer most constrained; for now, it is simply the first one encountered.
*/ */
Goal Binding
select_goal () select_goal ()
{ {
Goal goal; List bl;
int run; Binding best;
goal.run = INVALID; best = NULL;
goal.rd = NULL; bl = sys->bindings;
for (run = 0; run < sys->maxruns; run++) while (bl != NULL)
{ {
Roledef rd; Binding b;
int index;
index = 0; b = (Binding) bl->data;
rd = sys->runs[run].start; if (!b->done)
while (rd != NULL && index < sys->runs[run].length)
{ {
if (isGoal (rd) && !isBound (rd)) // For now, we simply take the first encountered goal
{ return b;
// Return this goal
goal.run = run;
goal.index = index;
goal.rd = rd;
return goal;
}
index++;
rd = rd->next;
} }
bl = bl->next;
} }
return goal; return best;
} }
//! Bind a regular goal //! Bind a regular goal
int int
bind_goal_regular (const Goal goal) bind_goal_regular (const Binding b)
{ {
int flag; int flag;
/* /*
@ -594,7 +591,7 @@ bind_goal_regular (const Goal goal)
eprintf (", index %i\n", index); eprintf (", index %i\n", index);
} }
#endif #endif
if (!termMguInTerm (goal.rd->message, rd->message, test_unification)) if (!termMguInTerm (b->term, rd->message, test_unification))
{ {
// A good candidate // A good candidate
#ifdef DEBUG #ifdef DEBUG
@ -602,14 +599,14 @@ bind_goal_regular (const Goal goal)
{ {
indentPrint (); indentPrint ();
eprintf ("Term "); eprintf ("Term ");
termPrint (goal.rd->message); termPrint (b->term);
eprintf (" can possibly be bound by role "); eprintf (" can possibly be bound by role ");
termPrint (r->nameterm); termPrint (r->nameterm);
eprintf (", index %i\n", index); eprintf (", index %i\n", index);
} }
#endif #endif
return (bind_new_run (goal, p, r, index, 0) && return (bind_new_run (b, p, r, index, 0) &&
bind_existing_run (goal, p, r, index, 0)); bind_existing_run (b, p, r, index, 0));
} }
else else
{ {
@ -635,12 +632,13 @@ bind_goal_regular (const Goal goal)
eprintf ("Try intruder send.\n"); eprintf ("Try intruder send.\n");
} }
#endif #endif
return (flag && add_intruder_goal_iterate (goal)); return flag;
// return (flag && add_intruder_goal_iterate (b));
} }
//! Bind an intruder goal to a regular run //! Bind an intruder goal to a regular run
int int
bind_intruder_to_regular (Goal goal) bind_intruder_to_regular (Binding b)
{ {
int bind_this_roleevent (Protocol p, Role r, Roledef rd, int index) int bind_this_roleevent (Protocol p, Role r, Roledef rd, int index)
{ {
@ -662,7 +660,7 @@ bind_intruder_to_regular (Goal goal)
else else
{ // Test for subterm unification { // Test for subterm unification
if (termMguSubTerm if (termMguSubTerm
(goal.rd->message, rd->message, test_unification, (b->term, rd->message, test_unification,
sys->know->inverses, NULL)) sys->know->inverses, NULL))
{ {
// cannot unify // cannot unify
@ -673,8 +671,8 @@ bind_intruder_to_regular (Goal goal)
/** /**
* Either from an existing, or from a new run. * Either from an existing, or from a new run.
*/ */
return (bind_new_run (goal, p, r, index, 1) return (bind_new_run (b, p, r, index, 1)
&& bind_existing_run (goal, p, r, index, 1)); && bind_existing_run (b, p, r, index, 1));
} }
} }
} }
@ -688,7 +686,7 @@ bind_intruder_to_regular (Goal goal)
* Handles the case where the intruder constructs a composed term himself. * Handles the case where the intruder constructs a composed term himself.
*/ */
int int
bind_intruder_to_construct (const Goal goal) bind_intruder_to_construct (const Binding b)
{ {
Term term; Term term;
Termlist m0tl; Termlist m0tl;
@ -696,7 +694,7 @@ bind_intruder_to_construct (const Goal goal)
int run; int run;
flag = 1; flag = 1;
term = goal.rd->message; term = b->term;
/** /**
* Two options. * Two options.
* *
@ -719,19 +717,11 @@ bind_intruder_to_construct (const Goal goal)
t2 = term->right.key; t2 = term->right.key;
} }
run = create_intruder_goal (t1); goal_add (t1, b->run_to, b->ev_to);
if (binding_add (run, 0, goal.run, goal.index, t1)) goal_add (t2, b->run_to, b->ev_to);
{ flag = flag && iterate ();
run = create_intruder_goal (t2); goal_remove_last ();
if (binding_add (run, 0, goal.run, goal.index, t2)) goal_remove_last ();
{
flag = flag && iterate ();
}
binding_remove_last ();
roleInstanceDestroy (sys);
}
binding_remove_last ();
roleInstanceDestroy (sys);
} }
/** /**
* 2. Retrieved from M_0 * 2. Retrieved from M_0
@ -752,7 +742,7 @@ bind_intruder_to_construct (const Goal goal)
run = sys->maxruns - 1; run = sys->maxruns - 1;
sys->runs[run].start->message = termDuplicate (term); sys->runs[run].start->message = termDuplicate (term);
sys->runs[run].length = 1; sys->runs[run].length = 1;
if (binding_add (run, 0, goal.run, goal.index, term)) if (goal_bind (b, run, 0))
{ {
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (3)) if (DEBUGL (3))
@ -765,8 +755,7 @@ bind_intruder_to_construct (const Goal goal)
#endif #endif
iterate (); iterate ();
} }
binding_remove_last (); goal_unbind (b);
roleInstanceDestroy (sys);
termlistSubstReset (subst); termlistSubstReset (subst);
termlistDelete (subst); termlistDelete (subst);
} }
@ -786,7 +775,7 @@ bind_intruder_to_construct (const Goal goal)
* Computes F2 as in Athena explanations. * Computes F2 as in Athena explanations.
*/ */
int int
bind_goal_intruder (const Goal goal) bind_goal_intruder (const Binding b)
{ {
/** /**
* Special case: when the intruder can bind it to the initial knowledge. * Special case: when the intruder can bind it to the initial knowledge.
@ -801,7 +790,7 @@ bind_goal_intruder (const Goal goal)
int hasvars; int hasvars;
Termlist substlist; Termlist substlist;
substlist = termMguTerm (tl->term, goal.rd->message); substlist = termMguTerm (tl->term, b->term);
if (substlist != MGUFAIL) if (substlist != MGUFAIL)
{ {
// This seems to work // This seems to work
@ -812,27 +801,25 @@ bind_goal_intruder (const Goal goal)
tl = tl->next; tl = tl->next;
} }
termlistDelete (tl); termlistDelete (tl);
return (flag && bind_intruder_to_regular (goal) && return (flag && bind_intruder_to_regular (b) &&
bind_intruder_to_construct (goal)); bind_intruder_to_construct (b));
} }
//! Bind a goal in all possible ways //! Bind a goal in all possible ways
int int
bind_goal (const Goal goal) bind_goal (const Binding b)
{ {
if (!goal.rd->bound) if (!b->done)
{ {
int flag; int flag;
goal.rd->bound = 1; if (sys->runs[b->run_to].protocol == INTRUDER)
if (sys->runs[goal.run].protocol == INTRUDER)
{ {
flag = bind_goal_intruder (goal); flag = bind_goal_intruder (b);
} }
else else
{ {
flag = bind_goal_regular (goal); flag = bind_goal_regular (b);
} }
goal.rd->bound = 0;
return flag; return flag;
} }
else else
@ -923,14 +910,14 @@ prune ()
} }
//! Setup system for specific claim test //! Setup system for specific claim test
add_claim_specifics (Claimlist cl, Roledef rd) add_claim_specifics (const Claimlist cl, const Roledef rd)
{ {
if (cl->type == CLAIM_Secret) if (cl->type == CLAIM_Secret)
{ {
/** /**
* Secrecy claim * Secrecy claim
*/ */
create_intruder_goal (rd->message); goal_add (rd->message, 0, cl->ev); // Assumption that all claims are in run 0
} }
} }
@ -943,12 +930,13 @@ int
iterate () iterate ()
{ {
int flag; int flag;
Goal goal;
flag = 1; flag = 1;
indentDepth++; indentDepth++;
if (!prune ()) if (!prune ())
{ {
Binding b;
/** /**
* Not pruned: count * Not pruned: count
*/ */
@ -987,8 +975,8 @@ iterate ()
* Check whether its a final state (i.e. all goals bound) * Check whether its a final state (i.e. all goals bound)
*/ */
goal = select_goal (); b = select_goal ();
if (goal.run == INVALID) if (b != NULL)
{ {
/* /*
* all goals bound, check for property * all goals bound, check for property
@ -1009,14 +997,14 @@ iterate ()
{ {
indentPrint (); indentPrint ();
eprintf ("Trying to bind goal "); eprintf ("Trying to bind goal ");
termPrint (goal.rd->message); termPrint (b->term);
eprintf (" from run %i, index %i.\n", goal.run, goal.index); eprintf (" from run %i, index %i.\n", b->run_to, b->ev_to);
} }
#endif #endif
/* /*
* bind this goal in all possible ways and iterate * bind this goal in all possible ways and iterate
*/ */
flag = bind_goal (goal); flag = bind_goal (b);
} }
} }
#ifdef DEBUG #ifdef DEBUG
@ -1105,7 +1093,7 @@ arachne ()
#endif #endif
roleInstance (sys, p, r, NULL, NULL); roleInstance (sys, p, r, NULL, NULL);
sys->runs[0].length = cl->ev + 1; add_read_goals (sys->maxruns - 1, 0, cl->ev + 1);
/** /**
* Add specific goal info * Add specific goal info

View File

@ -45,7 +45,7 @@ binding_destroy (Binding b)
{ {
if (b->done) if (b->done)
{ {
goal_unbind (); goal_unbind (b);
} }
memFree (b, sizeof (struct binding)); memFree (b, sizeof (struct binding));
} }
@ -77,6 +77,16 @@ bindingDone ()
list_destroy (sys->bindings); list_destroy (sys->bindings);
} }
//! Destroy graph
void goal_graph_destroy ()
{
if (graph != NULL)
{
memFree (graph, (nodes * nodes) * sizeof (int));
graph = NULL;
}
}
//! Compute unclosed graph //! Compute unclosed graph
void goal_graph_create () void goal_graph_create ()
{ {
@ -122,16 +132,6 @@ void goal_graph_create ()
} }
} }
//! Destroy graph
void goal_graph_destroy ()
{
if (graph != NULL)
{
memFree (graph, (nodes * nodes) * sizeof (int));
graph = NULL;
}
}
/** /**
* *
@ -318,7 +318,7 @@ int bindings_c_minimal ()
{ {
Binding b; Binding b;
int run; int run;
int node_to; int node_from;
b = (Binding) bl->data; b = (Binding) bl->data;
node_from = node_number (b->run_from, b->ev_from); node_from = node_number (b->run_from, b->ev_from);