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
|
2005-06-07 16:02:27 +01:00
|
|
|
#include "switches.h"
|
2005-06-16 15:10:07 +01:00
|
|
|
#include "specialterm.h"
|
2006-08-01 08:31:40 +01:00
|
|
|
#include "claim.h"
|
|
|
|
#include "dotout.h"
|
2007-01-06 14:45:29 +00:00
|
|
|
#include "type.h"
|
2005-05-01 14:32:50 +01:00
|
|
|
|
|
|
|
#include "xmlout.h"
|
|
|
|
|
2005-05-12 14:18:37 +01:00
|
|
|
/*
|
|
|
|
* Externally defined
|
|
|
|
*/
|
|
|
|
extern Protocol INTRUDER; // from arachne.c
|
2005-11-12 21:13:00 +00:00
|
|
|
extern Term TERM_Data; // from specialterm.c
|
2005-05-12 14:18:37 +01:00
|
|
|
|
2005-05-01 14:32:50 +01:00
|
|
|
/*
|
|
|
|
* Global/static stuff.
|
|
|
|
*/
|
|
|
|
static int xmlindent; // indent level for xml elements in output
|
2005-05-13 14:40:37 +01:00
|
|
|
static Term only_claim_label; // if NULL, show all claims in xml event lists. Otherwise, only this one.
|
2005-06-02 09:25:45 +01:00
|
|
|
static int show_substitution_path; // is only set to true for variable printing, normally false.
|
2005-05-01 14:32:50 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Default external interface: init/done
|
|
|
|
*/
|
|
|
|
|
|
|
|
//! Init this module
|
|
|
|
void
|
|
|
|
xmlOutInit (void)
|
|
|
|
{
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("<scyther>\n");
|
2005-05-03 10:45:54 +01:00
|
|
|
xmlindent = 1;
|
2005-05-13 14:40:37 +01:00
|
|
|
only_claim_label = NULL;
|
2005-06-02 09:25:45 +01:00
|
|
|
show_substitution_path = false;
|
2005-05-01 14:32:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Close up
|
|
|
|
void
|
|
|
|
xmlOutDone (void)
|
|
|
|
{
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("</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-12-27 10:49:22 +00:00
|
|
|
eprintf (" ");
|
2005-05-01 14:32:50 +01:00
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//! XML print
|
|
|
|
/**
|
2005-12-27 10:49:22 +00:00
|
|
|
* Input is comparable to eprintf, but indents (according to xmlindent) and adds
|
2005-05-01 14:32:50 +01:00
|
|
|
* a newline.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xmlPrint (char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
xmlIndentPrint ();
|
|
|
|
va_start (args, fmt);
|
2005-12-30 12:03:19 +00:00
|
|
|
veprintf (fmt, args);
|
2005-05-01 14:32:50 +01:00
|
|
|
va_end (args);
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("\n");
|
2005-05-01 14:32:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Print a simple integer value element
|
|
|
|
void
|
|
|
|
xmlOutInteger (const char *tag, const int value)
|
|
|
|
{
|
|
|
|
xmlPrint ("<%s>%i</%s>", tag, value, tag);
|
|
|
|
}
|
|
|
|
|
2006-08-01 08:31:40 +01:00
|
|
|
//! Print a state counter element
|
|
|
|
void
|
|
|
|
xmlOutStates (const char *tag, states_t value)
|
|
|
|
{
|
|
|
|
xmlIndentPrint ();
|
|
|
|
eprintf ("<%s>", tag);
|
|
|
|
statesFormat (value);
|
|
|
|
eprintf ("</%s>\n", tag);
|
|
|
|
}
|
|
|
|
|
2005-05-12 14:18:37 +01:00
|
|
|
//! Print a term in XML form (iteration inner)
|
|
|
|
void
|
2005-06-02 09:25:45 +01:00
|
|
|
xmlTermPrintInner (Term term)
|
2005-05-12 14:18:37 +01:00
|
|
|
{
|
|
|
|
if (term != NULL)
|
|
|
|
{
|
2005-06-02 09:25:45 +01:00
|
|
|
if (!show_substitution_path)
|
|
|
|
{
|
|
|
|
/* In a normal situation, variables are immediately substituted, and
|
|
|
|
* only the result is output.
|
|
|
|
*/
|
|
|
|
term = deVar (term);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("<var name=\"");
|
2005-05-12 14:18:37 +01:00
|
|
|
if (term->subst == NULL)
|
|
|
|
{
|
|
|
|
// Free variable
|
2005-05-12 14:19:32 +01:00
|
|
|
termPrint (term); // Must be a normal termPrint
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("\" free=\"true\" />");
|
2005-05-12 14:18:37 +01:00
|
|
|
}
|
|
|
|
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;
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("\">");
|
2005-05-12 14:18:37 +01:00
|
|
|
xmlTermPrintInner (term->subst);
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("</var>");
|
2005-05-12 14:18:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Constant
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("<const>");
|
2005-05-12 14:19:32 +01:00
|
|
|
termPrint (term); // Must be a normal termPrint
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("</const>");
|
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 */
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("<apply><function>");
|
2005-05-12 14:18:37 +01:00
|
|
|
xmlTermPrintInner (TermKey (term));
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("</function><arg>");
|
2005-05-12 14:18:37 +01:00
|
|
|
xmlTermPrintInner (TermOp (term));
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("</arg></apply>");
|
2005-05-12 14:18:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("<encrypt><op>");
|
2005-05-12 14:19:32 +01:00
|
|
|
xmlTermPrintInner (TermOp (term));
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("</op><key>");
|
2005-05-12 14:19:32 +01:00
|
|
|
xmlTermPrintInner (TermKey (term));
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("</key></encrypt>");
|
2005-05-12 14:18:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Assume tuple
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("<tuple><op1>");
|
2005-05-12 14:19:32 +01:00
|
|
|
xmlTermPrintInner (TermOp1 (term));
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("</op1><op2>");
|
2005-05-12 14:19:32 +01:00
|
|
|
xmlTermPrintInner (TermOp2 (term));
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("</op2></tuple>");
|
2005-05-12 14:18:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Print a term in XML form (wrapper)
|
2005-06-02 09:25:45 +01:00
|
|
|
/**
|
|
|
|
* In the original setupt, a <term> wrapper was added. It is disabled for now.
|
|
|
|
* If this turns out to be the preferred situation, xmlTermPrintInner can be
|
|
|
|
* renamed to xmlTermPrint and all will be well.
|
|
|
|
*/
|
2005-05-12 14:18:37 +01:00
|
|
|
void
|
|
|
|
xmlTermPrint (const Term term)
|
|
|
|
{
|
2005-12-27 10:49:22 +00:00
|
|
|
// eprintf ("<term>");
|
2005-05-12 14:18:37 +01:00
|
|
|
xmlTermPrintInner (term);
|
2005-12-27 10:49:22 +00:00
|
|
|
// eprintf ("</term>");
|
2005-05-12 14:18:37 +01:00
|
|
|
}
|
|
|
|
|
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);
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("\n");
|
2005-05-12 15:52:50 +01:00
|
|
|
tl = tl->next;
|
|
|
|
}
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</termlist>");
|
|
|
|
}
|
|
|
|
|
2005-05-01 14:32:50 +01:00
|
|
|
//! Print a term for an element
|
2005-05-17 14:00:45 +01:00
|
|
|
/**
|
|
|
|
* If the first parameter (the tag) is NULL then only the term is printed without a wrapper tag.
|
|
|
|
*/
|
2005-05-01 14:32:50 +01:00
|
|
|
void
|
|
|
|
xmlOutTerm (const char *tag, const Term term)
|
|
|
|
{
|
|
|
|
if (term != NULL)
|
|
|
|
{
|
|
|
|
xmlIndentPrint ();
|
2005-05-17 14:00:45 +01:00
|
|
|
if (tag != NULL)
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("<%s>", tag);
|
2005-05-12 14:18:37 +01:00
|
|
|
xmlTermPrint (term);
|
2005-05-17 14:00:45 +01:00
|
|
|
if (tag != NULL)
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("</%s>", tag);
|
|
|
|
eprintf ("\n");
|
2005-05-01 14:32:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-06-02 09:25:45 +01:00
|
|
|
termPrint (t);
|
2005-05-02 14:38:45 +01:00
|
|
|
t->type = typebuffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-02 09:25:45 +01:00
|
|
|
//! Print a role term with <rolename> tag and indenting etc.
|
|
|
|
void
|
|
|
|
xmlRoleTermPrint (const Term t)
|
|
|
|
{
|
|
|
|
xmlIndentPrint ();
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("<rolename>");
|
2005-06-02 09:25:45 +01:00
|
|
|
roleTermPrint (t);
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("</rolename>\n");
|
2005-06-02 09:25:45 +01:00
|
|
|
}
|
|
|
|
|
2005-07-06 15:33:05 +01:00
|
|
|
//! Show a term and its type, on single lines
|
|
|
|
void
|
|
|
|
xmlTermType (const Term t)
|
|
|
|
{
|
|
|
|
Term substbuf;
|
|
|
|
|
|
|
|
if (realTermVariable (t))
|
|
|
|
{
|
|
|
|
substbuf = t->subst;
|
|
|
|
t->subst = NULL;
|
|
|
|
}
|
|
|
|
|
2005-09-08 14:30:00 +01:00
|
|
|
xmlindent++;
|
2005-11-12 21:13:00 +00:00
|
|
|
xmlPrint ("<term>");
|
2005-09-08 14:30:00 +01:00
|
|
|
xmlindent++;
|
2005-07-06 15:33:05 +01:00
|
|
|
xmlIndentPrint ();
|
|
|
|
xmlTermPrint (t);
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("\n");
|
2005-09-08 14:30:00 +01:00
|
|
|
xmlindent--;
|
2005-11-12 21:13:00 +00:00
|
|
|
xmlPrint ("</term>");
|
2005-09-08 14:30:00 +01:00
|
|
|
|
2005-11-12 21:13:00 +00:00
|
|
|
xmlPrint ("<type>");
|
2005-09-08 14:30:00 +01:00
|
|
|
xmlindent++;
|
2005-07-06 15:33:05 +01:00
|
|
|
xmlTermlistPrint (t->stype);
|
2005-09-08 14:30:00 +01:00
|
|
|
xmlindent--;
|
2005-11-12 21:13:00 +00:00
|
|
|
xmlPrint ("</type>");
|
2005-09-08 14:30:00 +01:00
|
|
|
xmlindent--;
|
2005-07-06 15:33:05 +01:00
|
|
|
|
|
|
|
if (realTermVariable (t))
|
|
|
|
{
|
|
|
|
t->subst = substbuf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-08 13:55:32 +01:00
|
|
|
//! Show a single variable instantiation
|
2005-07-06 15:33:05 +01:00
|
|
|
void
|
2005-09-08 13:55:32 +01:00
|
|
|
xmlVariable (const System sys, const Term variable, const int run)
|
2005-07-06 15:33:05 +01:00
|
|
|
{
|
|
|
|
if (realTermVariable (variable))
|
|
|
|
{
|
2005-09-08 13:55:32 +01:00
|
|
|
xmlIndentPrint ();
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("<variable typeflaw=\"");
|
2007-05-18 13:06:29 +01:00
|
|
|
/* TODO this is now wrong, because it does not switch the matching more
|
|
|
|
* anymore */
|
|
|
|
if (!checkTypeTerm (variable))
|
2005-09-08 13:55:32 +01:00
|
|
|
{
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("true");
|
2005-09-08 13:55:32 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("false");
|
2005-09-08 13:55:32 +01:00
|
|
|
}
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("\" run=\"%i\">\n", run);
|
2005-07-06 15:33:05 +01:00
|
|
|
xmlindent++;
|
2005-09-08 14:30:00 +01:00
|
|
|
|
|
|
|
xmlPrint ("<name>");
|
2005-07-06 15:33:05 +01:00
|
|
|
xmlTermType (variable);
|
2005-09-08 14:30:00 +01:00
|
|
|
xmlPrint ("</name>");
|
2005-09-08 13:55:32 +01:00
|
|
|
if (variable->subst != NULL)
|
|
|
|
{
|
2005-11-12 21:13:00 +00:00
|
|
|
xmlPrint ("<substitution>");
|
2005-09-08 13:55:32 +01:00
|
|
|
xmlTermType (deVar (variable));
|
2005-11-12 21:13:00 +00:00
|
|
|
xmlPrint ("</substitution>");
|
2005-09-08 13:55:32 +01:00
|
|
|
}
|
2005-07-06 15:33:05 +01:00
|
|
|
xmlindent--;
|
2005-09-08 13:55:32 +01:00
|
|
|
xmlPrint ("</variable>");
|
2005-07-06 15:33:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-02 15:22:25 +00:00
|
|
|
//! Show variable instantiations
|
|
|
|
/**
|
|
|
|
* Show the instantiations of all variables. Maybe we need to restrict this,
|
|
|
|
* and scan only for those variables that actually occur in the semitrace.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xmlRunVariables (const System sys, const int run)
|
|
|
|
{
|
|
|
|
int prev_mode; // buffer for show mode
|
|
|
|
Termlist varlist;
|
|
|
|
|
|
|
|
prev_mode = show_substitution_path;
|
|
|
|
show_substitution_path = true;
|
|
|
|
xmlPrint ("<variables>");
|
|
|
|
xmlindent++;
|
|
|
|
|
|
|
|
varlist = sys->runs[run].sigma;
|
|
|
|
while (varlist != NULL)
|
|
|
|
{
|
|
|
|
xmlVariable (sys, varlist->term, run);
|
|
|
|
varlist = varlist->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</variables>");
|
|
|
|
show_substitution_path = prev_mode;
|
|
|
|
}
|
|
|
|
|
2005-09-08 13:55:32 +01:00
|
|
|
//! Show variable instantiations
|
2005-07-06 15:33:05 +01:00
|
|
|
/**
|
2005-09-08 13:55:32 +01:00
|
|
|
* Show the instantiations of all variables. Maybe we need to restrict this,
|
|
|
|
* and scan only for those variables that actually occur in the semitrace.
|
2005-07-06 15:33:05 +01:00
|
|
|
*/
|
|
|
|
void
|
2005-09-08 13:55:32 +01:00
|
|
|
xmlVariables (const System sys)
|
2005-07-06 15:33:05 +01:00
|
|
|
{
|
2005-09-08 13:55:32 +01:00
|
|
|
int prev_mode; // buffer for show mode
|
|
|
|
int run; // for loop
|
2005-07-06 15:33:05 +01:00
|
|
|
|
2005-09-08 13:55:32 +01:00
|
|
|
prev_mode = show_substitution_path;
|
|
|
|
show_substitution_path = true;
|
|
|
|
xmlPrint ("<variables>");
|
|
|
|
xmlindent++;
|
2005-07-06 15:33:05 +01:00
|
|
|
run = 0;
|
|
|
|
while (run < sys->maxruns)
|
|
|
|
{
|
|
|
|
if (sys->runs[run].protocol != INTRUDER)
|
|
|
|
{
|
|
|
|
Termlist varlist;
|
|
|
|
|
|
|
|
varlist = sys->runs[run].locals;
|
|
|
|
while (varlist != NULL)
|
|
|
|
{
|
2005-09-08 13:55:32 +01:00
|
|
|
if (realTermVariable (varlist->term))
|
2005-07-06 15:33:05 +01:00
|
|
|
{
|
2005-09-08 13:55:32 +01:00
|
|
|
xmlVariable (sys, varlist->term, run);
|
2005-07-06 15:33:05 +01:00
|
|
|
}
|
|
|
|
varlist = varlist->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
run++;
|
|
|
|
}
|
2005-09-08 13:55:32 +01:00
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</variables>");
|
|
|
|
show_substitution_path = prev_mode;
|
2005-07-06 15:33:05 +01:00
|
|
|
}
|
|
|
|
|
2005-05-17 14:00:45 +01:00
|
|
|
//! Show inverses
|
|
|
|
void
|
|
|
|
xmlInverses (const System sys)
|
|
|
|
{
|
|
|
|
Termlist invlist;
|
|
|
|
|
|
|
|
xmlPrint ("<inversekeys>");
|
|
|
|
xmlindent++;
|
|
|
|
invlist = sys->know->inverses;
|
|
|
|
while (invlist != NULL && invlist->next != NULL)
|
|
|
|
{
|
|
|
|
xmlPrint ("<keypair>");
|
|
|
|
xmlindent++;
|
|
|
|
xmlOutTerm (NULL, invlist->term);
|
|
|
|
xmlOutTerm (NULL, invlist->next->term);
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</keypair>");
|
|
|
|
|
|
|
|
invlist = invlist->next->next;
|
|
|
|
}
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</inversekeys>");
|
|
|
|
}
|
|
|
|
|
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-17 14:00:45 +01:00
|
|
|
xmlInverses (sys);
|
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
|
|
|
}
|
|
|
|
|
2005-05-13 14:40:37 +01:00
|
|
|
//! Determine whether to show an event
|
|
|
|
int
|
2005-06-02 09:25:45 +01:00
|
|
|
isEventInteresting (const System sys, const Roledef rd)
|
2005-05-13 14:40:37 +01:00
|
|
|
{
|
2005-06-07 16:02:27 +01:00
|
|
|
if (switches.human)
|
2005-05-13 14:40:37 +01:00
|
|
|
{
|
2005-06-02 09:25:45 +01:00
|
|
|
if (rd->type != CLAIM)
|
2005-05-13 14:40:37 +01:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-06-02 09:25:45 +01:00
|
|
|
// A claim
|
|
|
|
if (only_claim_label == NULL)
|
2005-05-13 14:40:37 +01:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2005-06-02 09:25:45 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (isTermEqual (only_claim_label, rd->label))
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2005-05-13 14:40:37 +01:00
|
|
|
}
|
2005-06-02 09:25:45 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 1;
|
2005-05-13 14:40:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2005-06-02 09:25:45 +01:00
|
|
|
if (!isEventInteresting (sys, rd))
|
2005-05-13 14:40:37 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-05-01 14:32:50 +01:00
|
|
|
xmlIndentPrint ();
|
|
|
|
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("<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:
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("read");
|
2005-05-01 14:32:50 +01:00
|
|
|
break;
|
|
|
|
case SEND:
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("send");
|
2005-05-01 14:32:50 +01:00
|
|
|
break;
|
|
|
|
case CLAIM:
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("claim");
|
2005-05-01 14:32:50 +01:00
|
|
|
break;
|
|
|
|
default:
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("unknown code=\"%i\"", rd->type);
|
2005-05-01 14:32:50 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("\"");
|
|
|
|
eprintf (" index=\"%i\"", index);
|
|
|
|
eprintf (">\n");
|
2005-05-12 14:18:37 +01:00
|
|
|
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 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);
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("\n");
|
2005-05-12 14:19:32 +01:00
|
|
|
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)
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("<blocked />");
|
2005-05-12 14:19:32 +01:00
|
|
|
xmlIndentPrint ();
|
|
|
|
xmlTermPrint (b->term);
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("\n");
|
2005-05-12 14:19:32 +01:00
|
|
|
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)
|
|
|
|
{
|
2005-06-02 09:25:45 +01:00
|
|
|
xmlPrint ("<eventlist>");
|
|
|
|
xmlindent++;
|
2005-05-12 15:52:50 +01:00
|
|
|
while (rd != NULL)
|
|
|
|
{
|
|
|
|
xmlOutEvent (sys, rd, -1, index);
|
|
|
|
index++;
|
|
|
|
rd = rd->next;
|
|
|
|
}
|
2005-06-02 09:25:45 +01:00
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</eventlist>");
|
2005-05-12 15:52:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//! 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++;
|
2005-06-02 09:25:45 +01:00
|
|
|
xmlRoleTermPrint (r->nameterm);
|
2005-05-12 15:52:50 +01:00
|
|
|
xmlRoleEventlist (sys, r->roledef, 0);
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</role>");
|
|
|
|
r = r->next;
|
|
|
|
}
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</protocol>");
|
|
|
|
}
|
|
|
|
p = p->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-01 14:46:18 +01:00
|
|
|
//! Untrusted agents
|
|
|
|
void
|
|
|
|
xmlUntrustedAgents (const System sys)
|
|
|
|
{
|
|
|
|
xmlPrint ("<untrusted>");
|
|
|
|
xmlindent++;
|
|
|
|
xmlTermlistPrint (sys->untrusted);
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</untrusted>");
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Commandline
|
|
|
|
void
|
|
|
|
xmlOutCommandline (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
xmlPrint ("<commandline>");
|
|
|
|
xmlindent++;
|
|
|
|
i = 0;
|
|
|
|
while (i < switches.argc)
|
|
|
|
{
|
|
|
|
xmlPrint ("<arg>%s</arg>", switches.argv[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</commandline>");
|
|
|
|
}
|
|
|
|
|
2005-05-12 15:52:50 +01:00
|
|
|
//! Global system info
|
|
|
|
/**
|
|
|
|
* To be used by concrete trace as well as semitrace output
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
xmlOutSysInfo (const System sys)
|
|
|
|
{
|
|
|
|
xmlPrint ("<system>");
|
|
|
|
xmlindent++;
|
|
|
|
|
2005-07-01 14:46:18 +01:00
|
|
|
xmlOutCommandline ();
|
2005-06-07 16:02:27 +01:00
|
|
|
xmlOutInteger ("match", switches.match);
|
2005-05-12 15:52:50 +01:00
|
|
|
|
|
|
|
xmlInitialKnowledge (sys);
|
|
|
|
xmlInvolvedProtocolRoles (sys);
|
2005-07-01 14:46:18 +01:00
|
|
|
xmlUntrustedAgents (sys);
|
2005-05-12 15:52:50 +01:00
|
|
|
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>");
|
2005-06-02 09:25:45 +01:00
|
|
|
xmlindent++;
|
|
|
|
xmlRoleTermPrint (roles->term);
|
2005-05-12 15:52:50 +01:00
|
|
|
xmlOutTerm ("agent", deVar (agentOfRunRole (sys, run, roles->term)));
|
2005-06-02 09:25:45 +01:00
|
|
|
xmlindent--;
|
2005-05-12 15:52:50 +01:00
|
|
|
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 ();
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("<protocol");
|
2005-05-12 15:52:50 +01:00
|
|
|
if (sys->runs[run].protocol == INTRUDER)
|
|
|
|
{
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf (" intruder=\"true\"");
|
2005-05-12 15:52:50 +01:00
|
|
|
}
|
2005-07-01 14:25:54 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Non-intruder run, check whether communicates with untrusted agents
|
|
|
|
if (!isRunTrusted (sys, run))
|
|
|
|
{
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf (" untrustedrun=\"true\"");
|
2005-07-01 14:25:54 +01:00
|
|
|
}
|
|
|
|
}
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf (">");
|
2005-05-12 15:52:50 +01:00
|
|
|
xmlTermPrint (sys->runs[run].protocol->nameterm);
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf ("</protocol>\n");
|
2005-05-12 15:52:50 +01:00
|
|
|
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;
|
2005-06-02 09:25:45 +01:00
|
|
|
xmlRoleTermPrint (r->nameterm);
|
2005-05-12 15:52:50 +01:00
|
|
|
/* reinstate substitution */
|
|
|
|
r->nameterm->subst = oldagent;
|
|
|
|
if (oldagent != NULL)
|
|
|
|
{
|
|
|
|
xmlOutTerm ("agent", r->nameterm);
|
|
|
|
}
|
|
|
|
xmlAgentsOfRunPrint (sys, run);
|
2007-01-02 15:22:25 +00:00
|
|
|
xmlRunVariables (sys, run);
|
2005-05-12 15:52:50 +01:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2005-06-21 12:04:34 +01:00
|
|
|
//! Test whether to display this event
|
|
|
|
/**
|
|
|
|
* Could be integrated into a single line on the while loop,
|
|
|
|
* but that makes it rather hard to understand.
|
|
|
|
*/
|
|
|
|
int showthis (void)
|
|
|
|
{
|
|
|
|
if (rd != NULL)
|
|
|
|
{
|
|
|
|
if (index < sys->runs[run].step)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-08-12 13:13:50 +01:00
|
|
|
if (switches.extendTrivial || switches.extendNonReads)
|
2005-06-21 12:04:34 +01:00
|
|
|
{
|
|
|
|
if (rd->type != READ)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2005-08-12 13:13:50 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (switches.extendTrivial)
|
|
|
|
{
|
|
|
|
/* This is a read, and we don't know whether to
|
|
|
|
* include it. Default behaviour would be to jump
|
|
|
|
* out of the conditions, and return false.
|
|
|
|
* Instead, we check whether it can be trivially
|
|
|
|
* satisfied by the knowledge from the preceding
|
|
|
|
* events.
|
|
|
|
*/
|
|
|
|
if (isTriviallyKnownAtArachne (sys,
|
|
|
|
rd->message,
|
|
|
|
run, index))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We cannot extend it trivially, based on
|
|
|
|
* the preceding events, but maybe we can
|
|
|
|
* base it on another (*all*) event. That
|
|
|
|
* would in fact introduce another implicit
|
|
|
|
* binding. Currently, we do not explicitly
|
|
|
|
* introduce this binding, but just allow
|
|
|
|
* displaying the event.
|
|
|
|
*
|
|
|
|
* TODO consider what it means to leave out
|
|
|
|
* this binding.
|
|
|
|
*/
|
|
|
|
if (isTriviallyKnownAfterArachne
|
|
|
|
(sys, rd->message, run, index))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-06-21 12:04:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-05-01 14:32:50 +01:00
|
|
|
index = 0;
|
|
|
|
rd = sys->runs[run].start;
|
2005-06-21 12:04:34 +01:00
|
|
|
while (showthis ())
|
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)
|
|
|
|
{
|
2005-05-13 14:40:37 +01:00
|
|
|
Term buffer_only_claim_label;
|
|
|
|
|
2005-05-01 14:32:50 +01:00
|
|
|
xmlIndentPrint ();
|
2005-12-30 12:17:25 +00:00
|
|
|
eprintf ("<state");
|
2005-05-01 14:32:50 +01:00
|
|
|
/* add trace length attribute */
|
2005-06-21 12:04:34 +01:00
|
|
|
/* Note that this is the length of the attack leading up to the broken
|
|
|
|
* claim, thus without any run extensions (--extend-nonreads).
|
|
|
|
*/
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf (" tracelength=\"%i\"", get_semitrace_length ());
|
2005-06-07 14:40:56 +01:00
|
|
|
/* add attack id attribute (within this scyther call) */
|
2005-12-27 10:49:22 +00:00
|
|
|
eprintf (" id=\"%i\"", sys->attackid);
|
|
|
|
eprintf (">\n");
|
2005-05-01 14:32:50 +01:00
|
|
|
xmlindent++;
|
2005-05-12 14:18:37 +01:00
|
|
|
|
|
|
|
/* mention the broken claim */
|
2005-05-13 14:40:37 +01:00
|
|
|
buffer_only_claim_label = only_claim_label;
|
2005-06-02 09:25:45 +01:00
|
|
|
only_claim_label = NULL;
|
2005-05-12 14:18:37 +01:00
|
|
|
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-13 14:40:37 +01:00
|
|
|
only_claim_label = sys->current_claim->label;
|
|
|
|
}
|
2005-06-02 09:25:45 +01:00
|
|
|
|
2005-05-01 14:32:50 +01:00
|
|
|
/* any global information about the system */
|
|
|
|
xmlOutSysInfo (sys);
|
2005-06-02 09:25:45 +01:00
|
|
|
/* instantiations of the variables */
|
|
|
|
xmlVariables (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>");
|
2006-08-01 08:31:40 +01:00
|
|
|
|
|
|
|
if (switches.dot)
|
|
|
|
{
|
|
|
|
// dot encapsulated in XML
|
|
|
|
xmlPrint ("<dot>");
|
|
|
|
dotSemiState (sys);
|
|
|
|
xmlPrint ("</dot>");
|
|
|
|
}
|
|
|
|
|
2005-05-01 14:32:50 +01:00
|
|
|
xmlindent--;
|
2005-12-30 12:17:25 +00:00
|
|
|
xmlPrint ("</state>");
|
2005-05-13 14:40:37 +01:00
|
|
|
|
|
|
|
/* restore only claim buffer */
|
|
|
|
only_claim_label = buffer_only_claim_label;
|
2005-05-01 14:32:50 +01:00
|
|
|
}
|
2006-08-01 08:31:40 +01:00
|
|
|
|
|
|
|
//! Output for a claim
|
|
|
|
void
|
|
|
|
xmlOutClaim (const System sys, Claimlist cl)
|
|
|
|
{
|
|
|
|
Protocol p;
|
|
|
|
|
|
|
|
p = (Protocol) cl->protocol;
|
|
|
|
|
|
|
|
xmlPrint ("<claimstatus>");
|
|
|
|
xmlindent++;
|
2006-08-01 12:20:53 +01:00
|
|
|
xmlOutTerm ("claimtype", cl->type);
|
2006-08-01 08:31:40 +01:00
|
|
|
xmlOutTerm ("label", cl->label);
|
|
|
|
xmlOutTerm ("protocol", p->nameterm);
|
|
|
|
xmlOutTerm ("role", cl->rolename);
|
|
|
|
xmlOutTerm ("parameter", cl->parameter);
|
|
|
|
|
|
|
|
if (!isTermEqual (cl->type, CLAIM_Empty))
|
|
|
|
{
|
|
|
|
|
|
|
|
// something to say about it
|
|
|
|
xmlOutStates ("failed", cl->failed);
|
|
|
|
xmlOutStates ("count", cl->count);
|
|
|
|
xmlOutStates ("states", cl->states);
|
|
|
|
if (cl->complete)
|
|
|
|
{
|
|
|
|
xmlPrint ("<complete />");
|
|
|
|
}
|
|
|
|
if (cl->timebound)
|
|
|
|
{
|
|
|
|
xmlPrint ("<timebound />");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlindent--;
|
|
|
|
xmlPrint ("</claimstatus>");
|
|
|
|
}
|