2005-05-01 14:32:50 +01:00
|
|
|
/*
|
|
|
|
* xmlout.c
|
|
|
|
*
|
|
|
|
* XML output for Scyther
|
|
|
|
*
|
|
|
|
* Module to output detailed Scyther information in XML format, for easier
|
|
|
|
* interaction with external programs. Originally developed for attack output
|
|
|
|
* details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "term.h"
|
|
|
|
#include "termlist.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "binding.h"
|
|
|
|
#include "arachne.h" // for get_semitrace_length
|
|
|
|
|
|
|
|
#include "xmlout.h"
|
|
|
|
|
2005-05-12 14:18:37 +01:00
|
|
|
/*
|
|
|
|
* Externally defined
|
|
|
|
*/
|
|
|
|
extern Protocol INTRUDER; // from arachne.c
|
|
|
|
extern Term TERM_Function; // from termlist.c
|
|
|
|
|
2005-05-01 14:32:50 +01:00
|
|
|
/*
|
|
|
|
* Global/static stuff.
|
|
|
|
*/
|
|
|
|
static int xmlindent; // indent level for xml elements in output
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Default external interface: init/done
|
|
|
|
*/
|
|
|
|
|
|
|
|
//! Init this module
|
|
|
|
void
|
|
|
|
xmlOutInit (void)
|
|
|
|
{
|
2005-05-03 10:45:54 +01:00
|
|
|
printf ("<scyther>\n");
|
|
|
|
xmlindent = 1;
|
2005-05-01 14:32:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Close up
|
|
|
|
void
|
|
|
|
xmlOutDone (void)
|
|
|
|
{
|
2005-05-03 10:45:54 +01:00
|
|
|
printf ("</scyther>\n");
|
2005-05-01 14:32:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local code, needed for any further real code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
//! Indent code
|
|
|
|
void
|
|
|
|
xmlIndentPrint ()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
i = xmlindent;
|
|
|
|
while (i > 0)
|
|
|
|
{
|
2005-05-03 10:45:54 +01:00
|
|
|
printf (" ");
|
2005-05-01 14:32:50 +01:00
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//! XML print
|
|
|
|
/**
|
|
|
|
* Input is comparable to printf, but indents (according to xmlindent) and adds
|
|
|
|
* a newline.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xmlPrint (char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
xmlIndentPrint ();
|
|
|
|
va_start (args, fmt);
|
|
|
|
vfprintf (stdout, fmt, args);
|
|
|
|
va_end (args);
|
|
|
|
printf ("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Print a simple integer value element
|
|
|
|
void
|
|
|
|
xmlOutInteger (const char *tag, const int value)
|
|
|
|
{
|
|
|
|
xmlPrint ("<%s>%i</%s>", tag, value, tag);
|
|
|
|
}
|
|
|
|
|
2005-05-12 14:18:37 +01:00
|
|
|
//! Print a term in XML form (iteration inner)
|
|
|
|
void
|
|
|
|
xmlTermPrintInner (const Term term)
|
|
|
|
{
|
|
|
|
if (term != NULL)
|
|
|
|
{
|
2005-05-12 14:19:32 +01:00
|
|
|
if (realTermLeaf (term))
|
2005-05-12 14:18:37 +01:00
|
|
|
{
|
|
|
|
// Variable?
|
|
|
|
if (realTermVariable (term))
|
|
|
|
{
|
|
|
|
Term substbuffer;
|
|
|
|
|
|
|
|
printf ("<var name=\"");
|
|
|
|
if (term->subst == NULL)
|
|
|
|
{
|
|
|
|
// Free variable
|
2005-05-12 14:19:32 +01:00
|
|
|
termPrint (term); // Must be a normal termPrint
|
2005-05-12 14:18:37 +01:00
|
|
|
printf ("\" free=\"true\" />");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Bound variable
|
|
|
|
substbuffer = term->subst; // Temporarily unsubst for printing
|
|
|
|
term->subst = NULL;
|
2005-05-12 14:19:32 +01:00
|
|
|
termPrint (term); // Must be a normal termPrint
|
2005-05-12 14:18:37 +01:00
|
|
|
term->subst = substbuffer;
|
|
|
|
printf ("\">");
|
|
|
|
xmlTermPrintInner (term->subst);
|
|
|
|
printf ("</var>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Constant
|
2005-05-12 14:19:32 +01:00
|
|
|
termPrint (term); // Must be a normal termPrint
|
2005-05-12 14:18:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Node
|
2005-05-12 14:19:32 +01:00
|
|
|
if (realTermEncrypt (term))
|
2005-05-12 14:18:37 +01:00
|
|
|
{
|
|
|
|
if (isTermLeaf (TermKey (term))
|
|
|
|
&& inTermlist (TermKey (term)->stype, TERM_Function))
|
|
|
|
{
|
|
|
|
/* function application */
|
|
|
|
printf ("<apply><function>");
|
|
|
|
xmlTermPrintInner (TermKey (term));
|
|
|
|
printf ("</function><arg>");
|
|
|
|
xmlTermPrintInner (TermOp (term));
|
|
|
|
printf ("</arg></apply>");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-12 14:19:32 +01:00
|
|
|
printf ("<encrypt><op>");
|
|
|
|
xmlTermPrintInner (TermOp (term));
|
|
|
|
printf ("</op><key>");
|
|
|
|
xmlTermPrintInner (TermKey (term));
|
|
|
|
printf ("</key></encrypt>");
|
2005-05-12 14:18:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Assume tuple
|
|
|
|
printf ("<tuple><op1>");
|
2005-05-12 14:19:32 +01:00
|
|
|
xmlTermPrintInner (TermOp1 (term));
|
2005-05-12 14:18:37 +01:00
|
|
|
printf ("</op1><op2>");
|
2005-05-12 14:19:32 +01:00
|
|
|
xmlTermPrintInner (TermOp2 (term));
|
2005-05-12 14:18:37 +01:00
|
|
|
printf ("</op2></tuple>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Print a term in XML form (wrapper)
|
|
|
|
void
|
|
|
|
xmlTermPrint (const Term term)
|
|
|
|
{
|
|
|
|
printf ("<term>");
|
|
|
|
xmlTermPrintInner (term);
|
|
|
|
printf ("</term>");
|
|
|
|
}
|
|
|
|
|
2005-05-12 15:52:50 +01:00
|
|
|
//! Print a termlist in XML form
|
|
|
|
void
|
|
|
|
xmlTermlistPrint (Termlist tl)
|
|
|
|
{
|
|
|
|
xmlPrint ("<termlist>");
|
|
|
|
xmlindent++;
|
|
|
|
while (tl != NULL)
|
|
|
|
{
|
|
|
|
xmlIndentPrint ();
|
|
|
|
xmlTermPrint (tl->term);
|
|
|
|
printf ("\n");
|
|
|
|
tl = tl->next;
|
|
|
|
}
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</termlist>");
|
|
|
|
}
|
|
|
|
|
2005-05-01 14:32:50 +01:00
|
|
|
//! Print a term for an element
|
|
|
|
void
|
|
|
|
xmlOutTerm (const char *tag, const Term term)
|
|
|
|
{
|
|
|
|
if (term != NULL)
|
|
|
|
{
|
|
|
|
xmlIndentPrint ();
|
|
|
|
printf ("<%s>", tag);
|
2005-05-12 14:18:37 +01:00
|
|
|
xmlTermPrint (term);
|
2005-05-01 14:32:50 +01:00
|
|
|
printf ("</%s>\n", tag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Attribute term
|
|
|
|
void
|
|
|
|
xmlAttrTerm (const char *tag, const Term term)
|
|
|
|
{
|
|
|
|
if (term != NULL)
|
|
|
|
{
|
|
|
|
printf (" %s=\"", tag);
|
2005-05-12 14:18:37 +01:00
|
|
|
xmlTermPrint (term);
|
2005-05-01 14:32:50 +01:00
|
|
|
printf ("\"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-02 14:38:45 +01:00
|
|
|
//! Print a term, known to be a role name
|
|
|
|
/**
|
|
|
|
* Arachne turns all role names into variables for convenience. Here we
|
|
|
|
* temporarily undo it for pretty-printing.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
roleTermPrint (const Term t)
|
|
|
|
{
|
|
|
|
if (t != NULL)
|
|
|
|
{
|
|
|
|
int typebuffer;
|
|
|
|
|
|
|
|
typebuffer = t->type;
|
|
|
|
t->type = GLOBAL;
|
2005-05-12 14:18:37 +01:00
|
|
|
xmlTermPrint (t);
|
2005-05-02 14:38:45 +01:00
|
|
|
t->type = typebuffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-12 15:52:50 +01:00
|
|
|
//! Show initial knowledge
|
2005-05-01 14:32:50 +01:00
|
|
|
void
|
2005-05-12 15:52:50 +01:00
|
|
|
xmlInitialKnowledge (const System sys)
|
2005-05-01 14:32:50 +01:00
|
|
|
{
|
2005-05-12 15:52:50 +01:00
|
|
|
Termlist knowlist;
|
2005-05-01 14:32:50 +01:00
|
|
|
|
2005-05-12 15:52:50 +01:00
|
|
|
xmlPrint ("<initialknowledge>");
|
2005-05-02 14:38:45 +01:00
|
|
|
xmlindent++;
|
2005-05-12 15:52:50 +01:00
|
|
|
knowlist = knowledgeSet (sys->know);
|
|
|
|
xmlTermlistPrint (knowlist);
|
|
|
|
termlistDelete (knowlist);
|
2005-05-02 14:38:45 +01:00
|
|
|
xmlindent--;
|
2005-05-12 15:52:50 +01:00
|
|
|
xmlPrint ("</initialknowledge>");
|
2005-05-02 14:38:45 +01:00
|
|
|
}
|
|
|
|
|
2005-05-12 15:52:50 +01:00
|
|
|
//! Determine whether a protocol is involved in the current semitrace.
|
|
|
|
int
|
|
|
|
isProtocolInvolved (const System sys, const Protocol p)
|
2005-05-01 14:32:50 +01:00
|
|
|
{
|
2005-05-12 15:52:50 +01:00
|
|
|
int run;
|
2005-05-01 14:32:50 +01:00
|
|
|
|
2005-05-12 15:52:50 +01:00
|
|
|
run = 0;
|
|
|
|
while (run < sys->maxruns)
|
2005-05-01 14:32:50 +01:00
|
|
|
{
|
2005-05-12 15:52:50 +01:00
|
|
|
if (sys->runs[run].protocol == p)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
run++;
|
2005-05-01 14:32:50 +01:00
|
|
|
}
|
2005-05-12 15:52:50 +01:00
|
|
|
return 0;
|
2005-05-01 14:32:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Show a single event from a run
|
|
|
|
/**
|
|
|
|
* run and index will only be output if they are nonnegative.
|
2005-05-12 14:18:37 +01:00
|
|
|
* Also prints any bindings, if this events follows some other events
|
|
|
|
* (typically when this is a read).
|
2005-05-12 15:52:50 +01:00
|
|
|
*
|
|
|
|
* If run < 0, it is assumed to be a role event, and thus no bindings will be shown.
|
2005-05-01 14:32:50 +01:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
xmlOutEvent (const System sys, Roledef rd, const int run, const int index)
|
|
|
|
{
|
|
|
|
xmlIndentPrint ();
|
|
|
|
|
2005-05-12 14:18:37 +01:00
|
|
|
printf ("<event type=\"");
|
2005-05-01 14:32:50 +01:00
|
|
|
switch (rd->type)
|
|
|
|
{
|
|
|
|
/* Read or send types are fairly similar.
|
|
|
|
* Currently, choose events are not distinguished yet. TODO
|
|
|
|
*/
|
|
|
|
case READ:
|
|
|
|
printf ("read");
|
|
|
|
break;
|
|
|
|
case SEND:
|
|
|
|
printf ("send");
|
|
|
|
break;
|
|
|
|
case CLAIM:
|
|
|
|
printf ("claim");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf ("unknown code=\"%i\"", rd->type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-05-12 14:18:37 +01:00
|
|
|
printf ("\"");
|
|
|
|
printf (" index=\"%i\"", index);
|
|
|
|
printf (">\n");
|
|
|
|
xmlindent++;
|
|
|
|
xmlOutTerm ("label", rd->label);
|
2005-05-01 14:32:50 +01:00
|
|
|
if (rd->type != CLAIM)
|
|
|
|
{
|
|
|
|
/* read or send */
|
2005-05-12 14:18:37 +01:00
|
|
|
xmlOutTerm ("from", rd->from);
|
|
|
|
xmlOutTerm ("to", rd->to);
|
|
|
|
xmlOutTerm ("message", rd->message);
|
2005-05-01 14:32:50 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* claim */
|
2005-05-12 14:18:37 +01:00
|
|
|
xmlOutTerm ("role", rd->from);
|
|
|
|
xmlOutTerm ("type", rd->to);
|
|
|
|
xmlOutTerm ("argument", rd->message);
|
2005-05-01 14:32:50 +01:00
|
|
|
}
|
|
|
|
|
2005-05-12 14:18:37 +01:00
|
|
|
|
|
|
|
// Display any incoming bindings
|
2005-05-12 14:19:32 +01:00
|
|
|
{
|
|
|
|
int incomingArrows;
|
|
|
|
|
|
|
|
int xmlBindingState (void *dt)
|
2005-05-01 14:32:50 +01:00
|
|
|
{
|
2005-05-12 14:19:32 +01:00
|
|
|
Binding b;
|
2005-05-12 14:18:37 +01:00
|
|
|
|
2005-05-12 14:19:32 +01:00
|
|
|
void xmlRunIndex (char *desc, const int run, const int index)
|
2005-05-12 14:18:37 +01:00
|
|
|
{
|
2005-05-12 14:19:32 +01:00
|
|
|
xmlPrint ("<%s run=\"%i\" index=\"%i\" />", desc, run, index);
|
|
|
|
}
|
2005-05-12 14:18:37 +01:00
|
|
|
|
2005-05-12 14:19:32 +01:00
|
|
|
b = (Binding) dt;
|
|
|
|
if (b->run_to == run && b->ev_to == index)
|
2005-05-12 14:18:37 +01:00
|
|
|
{
|
2005-05-12 14:19:32 +01:00
|
|
|
if (isTermVariable (b->term) && !b->done)
|
|
|
|
{
|
|
|
|
// Generate from m0
|
|
|
|
xmlPrint ("<choose>");
|
2005-05-12 14:18:37 +01:00
|
|
|
|
2005-05-12 14:19:32 +01:00
|
|
|
xmlindent++;
|
|
|
|
xmlIndentPrint ();
|
|
|
|
xmlTermPrint (b->term);
|
|
|
|
printf ("\n");
|
|
|
|
xmlindent--;
|
2005-05-12 14:18:37 +01:00
|
|
|
|
2005-05-12 14:19:32 +01:00
|
|
|
xmlPrint ("</choose>");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Normal binding
|
|
|
|
xmlPrint ("<follows>");
|
|
|
|
|
|
|
|
xmlindent++;
|
|
|
|
if (b->done)
|
|
|
|
xmlRunIndex ("after", b->run_from, b->ev_from);
|
|
|
|
else
|
|
|
|
xmlPrint ("<unbound />");
|
|
|
|
if (b->blocked)
|
|
|
|
printf ("<blocked />");
|
|
|
|
xmlIndentPrint ();
|
|
|
|
xmlTermPrint (b->term);
|
|
|
|
printf ("\n");
|
|
|
|
xmlindent--;
|
|
|
|
|
|
|
|
xmlPrint ("</follows>");
|
|
|
|
}
|
2005-05-12 14:18:37 +01:00
|
|
|
}
|
2005-05-12 14:19:32 +01:00
|
|
|
return 1;
|
2005-05-01 14:32:50 +01:00
|
|
|
}
|
2005-05-12 14:18:37 +01:00
|
|
|
|
2005-05-12 14:19:32 +01:00
|
|
|
xmlindent++;
|
2005-05-12 15:52:50 +01:00
|
|
|
// Only if real run, and not a roledef
|
|
|
|
if (run >= 0 && sys->bindings != NULL)
|
2005-05-12 14:19:32 +01:00
|
|
|
{
|
|
|
|
list_iterate (sys->bindings, xmlBindingState);
|
|
|
|
}
|
|
|
|
xmlindent--;
|
|
|
|
}
|
|
|
|
|
2005-05-12 14:18:37 +01:00
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</event>");
|
2005-05-01 14:32:50 +01:00
|
|
|
}
|
|
|
|
|
2005-05-12 15:52:50 +01:00
|
|
|
//! Print a list of role events, from a roledef pointer
|
|
|
|
void
|
|
|
|
xmlRoleEventlist (const System sys, Roledef rd, int index)
|
|
|
|
{
|
|
|
|
while (rd != NULL)
|
|
|
|
{
|
|
|
|
xmlOutEvent (sys, rd, -1, index);
|
|
|
|
index++;
|
|
|
|
rd = rd->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Show all protocol roles that are in the attack.
|
|
|
|
void
|
|
|
|
xmlInvolvedProtocolRoles (const System sys)
|
|
|
|
{
|
|
|
|
Protocol p;
|
|
|
|
|
|
|
|
p = sys->protocols;
|
|
|
|
while (p != NULL)
|
|
|
|
{
|
|
|
|
if (isProtocolInvolved (sys, p))
|
|
|
|
{
|
|
|
|
Role r;
|
|
|
|
|
|
|
|
xmlPrint ("<protocol>");
|
|
|
|
xmlindent++;
|
|
|
|
xmlOutTerm ("name", p->nameterm);
|
|
|
|
r = p->roles;
|
|
|
|
while (r != NULL)
|
|
|
|
{
|
|
|
|
xmlPrint ("<role>");
|
|
|
|
xmlindent++;
|
|
|
|
xmlOutTerm ("name", r->nameterm);
|
|
|
|
xmlRoleEventlist (sys, r->roledef, 0);
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</role>");
|
|
|
|
r = r->next;
|
|
|
|
}
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</protocol>");
|
|
|
|
}
|
|
|
|
p = p->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Global system info
|
|
|
|
/**
|
|
|
|
* To be used by concrete trace as well as semitrace output
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xmlOutSysInfo (const System sys)
|
|
|
|
{
|
|
|
|
xmlPrint ("<system>");
|
|
|
|
xmlindent++;
|
|
|
|
|
|
|
|
xmlOutInteger ("match", sys->match);
|
|
|
|
|
|
|
|
xmlInitialKnowledge (sys);
|
|
|
|
xmlInvolvedProtocolRoles (sys);
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</system>");
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Nicely format the role and agents we think we're talking to.
|
|
|
|
void
|
|
|
|
xmlAgentsOfRunPrint (const System sys, const int run)
|
|
|
|
{
|
|
|
|
Termlist roles;
|
|
|
|
|
|
|
|
xmlPrint ("<roleagents>");
|
|
|
|
xmlindent++;
|
|
|
|
|
|
|
|
roles = sys->runs[run].protocol->rolenames;
|
|
|
|
while (roles != NULL)
|
|
|
|
{
|
|
|
|
xmlPrint ("<role>");
|
|
|
|
xmlOutTerm ("name", roles->term);
|
|
|
|
xmlOutTerm ("agent", deVar (agentOfRunRole (sys, run, roles->term)));
|
|
|
|
xmlPrint ("</role>");
|
|
|
|
roles = roles->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</roleagents>");
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Static information about a run
|
|
|
|
void
|
|
|
|
xmlRunInfo (const System sys, const int run)
|
|
|
|
{
|
|
|
|
Role r;
|
|
|
|
Term oldagent;
|
|
|
|
|
|
|
|
xmlOutInteger ("runid", run);
|
|
|
|
xmlIndentPrint ();
|
|
|
|
printf ("<protocol");
|
|
|
|
if (sys->runs[run].protocol == INTRUDER)
|
|
|
|
{
|
|
|
|
printf (" intruder=\"true\"");
|
|
|
|
}
|
|
|
|
printf (">");
|
|
|
|
xmlTermPrint (sys->runs[run].protocol->nameterm);
|
|
|
|
printf ("</protocol>\n");
|
|
|
|
r = sys->runs[run].role;
|
|
|
|
|
|
|
|
/* undo substitution temporarily to retrieve role name */
|
|
|
|
/* Note that this is fairly tailored towards the Arachne method, TODO: make
|
|
|
|
* more generic. */
|
|
|
|
oldagent = r->nameterm->subst;
|
|
|
|
r->nameterm->subst = NULL;
|
|
|
|
xmlIndentPrint ();
|
|
|
|
printf ("<role>");
|
|
|
|
roleTermPrint (r->nameterm);
|
|
|
|
printf ("</role>\n");
|
|
|
|
/* reinstate substitution */
|
|
|
|
r->nameterm->subst = oldagent;
|
|
|
|
if (oldagent != NULL)
|
|
|
|
{
|
|
|
|
xmlOutTerm ("agent", r->nameterm);
|
|
|
|
}
|
|
|
|
xmlAgentsOfRunPrint (sys, run);
|
|
|
|
}
|
|
|
|
|
2005-05-01 14:32:50 +01:00
|
|
|
//! Display runs
|
|
|
|
void
|
|
|
|
xmlOutRuns (const System sys)
|
|
|
|
{
|
|
|
|
int run;
|
|
|
|
|
|
|
|
for (run = 0; run < sys->maxruns; run++)
|
|
|
|
{
|
|
|
|
xmlPrint ("<run>");
|
|
|
|
xmlindent++;
|
|
|
|
|
|
|
|
xmlRunInfo (sys, run);
|
|
|
|
|
|
|
|
xmlPrint ("<eventlist>");
|
|
|
|
xmlindent++;
|
|
|
|
{
|
|
|
|
Roledef rd;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
index = 0;
|
|
|
|
rd = sys->runs[run].start;
|
2005-05-04 13:06:30 +01:00
|
|
|
while (rd != NULL && index < sys->runs[run].step)
|
2005-05-01 14:32:50 +01:00
|
|
|
{
|
2005-05-12 14:18:37 +01:00
|
|
|
xmlOutEvent (sys, rd, run, index);
|
2005-05-01 14:32:50 +01:00
|
|
|
index++;
|
|
|
|
rd = rd->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</eventlist>");
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</run>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* -----------------------------------------------------------------------------------
|
|
|
|
* Publicly available functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
//! Output for a concrete trace (from modelchecker)
|
|
|
|
void
|
|
|
|
xmlOutTrace (const System sys)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Output for a semitrace (from arachne method)
|
|
|
|
/**
|
2005-05-02 14:38:45 +01:00
|
|
|
* Note: Uses get_trace_length(), which is defined for the arachne method
|
|
|
|
* only.
|
2005-05-01 14:32:50 +01:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
xmlOutSemitrace (const System sys)
|
|
|
|
{
|
|
|
|
xmlIndentPrint ();
|
|
|
|
printf ("<attack");
|
|
|
|
/* add trace length attribute */
|
|
|
|
printf (" tracelength=\"%i\"", get_semitrace_length ());
|
|
|
|
printf (">\n");
|
|
|
|
xmlindent++;
|
2005-05-12 14:18:37 +01:00
|
|
|
|
|
|
|
/* mention the broken claim */
|
|
|
|
if (sys->current_claim != NULL)
|
|
|
|
{
|
|
|
|
xmlPrint ("<broken>");
|
|
|
|
xmlindent++;
|
|
|
|
xmlOutTerm ("claim", sys->current_claim->type);
|
|
|
|
xmlOutTerm ("label", sys->current_claim->label);
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</broken>");
|
|
|
|
}
|
2005-05-01 14:32:50 +01:00
|
|
|
/* any global information about the system */
|
|
|
|
xmlOutSysInfo (sys);
|
2005-05-02 14:38:45 +01:00
|
|
|
/* semitrace */
|
2005-05-01 14:32:50 +01:00
|
|
|
xmlPrint ("<semitrace>");
|
|
|
|
xmlindent++;
|
|
|
|
xmlOutRuns (sys);
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</semitrace>");
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</attack>");
|
|
|
|
}
|