- Huge modification, now allowing for parbox constructions. Nearly all
overlap is gone now.
This commit is contained in:
parent
47a96937ac
commit
c53bff4f39
@ -1,12 +1,56 @@
|
|||||||
\documentclass{article}
|
\documentclass{article}
|
||||||
\usepackage{a4wide}
|
\usepackage{a4wide}
|
||||||
\usepackage{msc}
|
\usepackage{msc}
|
||||||
|
\usepackage{ifthen}
|
||||||
|
|
||||||
\setlength{\instwidth}{3.0cm}
|
\setlength{\instwidth}{3.0cm}
|
||||||
\setlength{\instdist}{4cm}
|
\setlength{\instdist}{4cm}
|
||||||
\setlength{\actionwidth}{3.6cm}
|
\setlength{\actionwidth}{3.6cm}
|
||||||
\setlength{\conditionoverlap}{1.9cm}
|
\setlength{\conditionoverlap}{1.9cm}
|
||||||
|
|
||||||
|
% Action macro from MSC documentation
|
||||||
|
|
||||||
|
\newsavebox{\labelbox}
|
||||||
|
\newlength{\oldwd}
|
||||||
|
\newlength{\oldht}
|
||||||
|
\newcommand{\Action}[2]{%
|
||||||
|
\setlength{\oldwd}{\actionwidth}%
|
||||||
|
\setlength{\oldht}{\actionheight}%
|
||||||
|
\savebox{\labelbox}{#1}%
|
||||||
|
\setlength{\actionwidth}{\wd\labelbox + 2\labeldist}%
|
||||||
|
\setlength{\actionheight}{\ht\labelbox + \dp\labelbox + 2\labeldist}%
|
||||||
|
\action{\usebox{\labelbox}}{#2}%
|
||||||
|
\setlength{\actionwidth}{\oldwd}%
|
||||||
|
\setlength{\actionheight}{\oldht}%
|
||||||
|
}
|
||||||
|
|
||||||
|
\newlength{\mscspacer}
|
||||||
|
\setlength{\mscspacer}{1ex}
|
||||||
|
|
||||||
|
\newcommand{\ActionBox}[2]{%
|
||||||
|
\Action{\parbox{\maxmscaction - 2\mscspacer}{\centering #1}}{#2}
|
||||||
|
}
|
||||||
|
|
||||||
|
\newlength{\maxtemp}
|
||||||
|
|
||||||
|
\newcommand{\maxlength}[2]{
|
||||||
|
\settowidth{\maxtemp}{#2}
|
||||||
|
\ifthenelse{\lengthtest{#1 < \maxtemp}}{\setlength{#1}{\maxtemp}}{}
|
||||||
|
\ifthenelse{\lengthtest{\maxmscall < \maxtemp}}{\setlength{\maxmscall}{\maxtemp}}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\newlength{\maxmscall}
|
||||||
|
\newlength{\maxmscinst}
|
||||||
|
\newlength{\maxmscaction}
|
||||||
|
\newlength{\maxmsccondition}
|
||||||
|
|
||||||
|
\setlength{\maxmscall}{\mscspacer}
|
||||||
|
\setlength{\maxmscinst}{\mscspacer}
|
||||||
|
\setlength{\maxmscaction}{\mscspacer}
|
||||||
|
\setlength{\maxmsccondition}{\mscspacer}
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
|
|
||||||
\input{attack}
|
\input{attack}
|
||||||
|
152
src/latex.c
152
src/latex.c
@ -35,6 +35,7 @@ struct traceinfo *tinfo;
|
|||||||
int width;
|
int width;
|
||||||
int landscape = 0;
|
int landscape = 0;
|
||||||
int *runPerm;
|
int *runPerm;
|
||||||
|
int pass;
|
||||||
|
|
||||||
/* code */
|
/* code */
|
||||||
|
|
||||||
@ -293,10 +294,19 @@ latexDeclInst (const System sys, int run)
|
|||||||
|
|
||||||
myAgent = agentOfRun (sys, run);
|
myAgent = agentOfRun (sys, run);
|
||||||
myRole = sys->runs[run].role->nameterm;
|
myRole = sys->runs[run].role->nameterm;
|
||||||
|
if (pass == 1)
|
||||||
|
{
|
||||||
|
printf ("\\maxlength{\\maxmscinst}{");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
printf ("\\declinst{run%i}{", run);
|
printf ("\\declinst{run%i}{", run);
|
||||||
|
}
|
||||||
|
|
||||||
/* display above assumptions */
|
/* display above assumptions */
|
||||||
roles = sys->runs[run].protocol->rolenames;
|
roles = sys->runs[run].protocol->rolenames;
|
||||||
|
if (pass == 2)
|
||||||
|
{
|
||||||
printf ("assumes $");
|
printf ("assumes $");
|
||||||
first = 1;
|
first = 1;
|
||||||
while (roles != NULL)
|
while (roles != NULL)
|
||||||
@ -313,10 +323,11 @@ latexDeclInst (const System sys, int run)
|
|||||||
}
|
}
|
||||||
roles = roles->next;
|
roles = roles->next;
|
||||||
}
|
}
|
||||||
printf ("$}{$");
|
printf ("$}{");
|
||||||
|
}
|
||||||
|
|
||||||
/* display agent and role */
|
/* display agent and role */
|
||||||
printf ("\\mathbf{");
|
printf ("$\\mathbf{");
|
||||||
termPrint (myAgent);
|
termPrint (myAgent);
|
||||||
printf("}: ");
|
printf("}: ");
|
||||||
termPrint (myRole);
|
termPrint (myRole);
|
||||||
@ -336,6 +347,12 @@ latexDeclInst (const System sys, int run)
|
|||||||
void
|
void
|
||||||
latexEventSpace (int amount)
|
latexEventSpace (int amount)
|
||||||
{
|
{
|
||||||
|
if (pass < 2)
|
||||||
|
{
|
||||||
|
/* not printing */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
//printf("%% number of newlines: %d\n",amount);
|
//printf("%% number of newlines: %d\n",amount);
|
||||||
for (i = 0; i < EVENTSPACE * amount; i++)
|
for (i = 0; i < EVENTSPACE * amount; i++)
|
||||||
@ -354,6 +371,12 @@ latexMessagePrint (struct tracebuf *tb, int from, int to)
|
|||||||
Term sendTerm = NULL;
|
Term sendTerm = NULL;
|
||||||
Term readTerm = NULL;
|
Term readTerm = NULL;
|
||||||
|
|
||||||
|
if (pass < 2)
|
||||||
|
{
|
||||||
|
/* no measurement of messages yet */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (from == -1 && to == -1)
|
if (from == -1 && to == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -415,6 +438,12 @@ latexMessagePrintHighlight (struct tracebuf *tb, int from, int to,
|
|||||||
Term sendTerm = NULL;
|
Term sendTerm = NULL;
|
||||||
Term readTerm = NULL;
|
Term readTerm = NULL;
|
||||||
|
|
||||||
|
if (pass < 2)
|
||||||
|
{
|
||||||
|
/* no measurements on message width yet */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (from == -1 && to == -1)
|
if (from == -1 && to == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -429,6 +458,7 @@ latexMessagePrintHighlight (struct tracebuf *tb, int from, int to,
|
|||||||
}
|
}
|
||||||
if (from == -1 && to != -1)
|
if (from == -1 && to != -1)
|
||||||
{
|
{
|
||||||
|
/* TODO redundant */
|
||||||
printf ("\\found{$");
|
printf ("\\found{$");
|
||||||
latexTermPrint (readTerm, highlight);
|
latexTermPrint (readTerm, highlight);
|
||||||
printf ("$}{}{run%d}\n", tb->run[to]);
|
printf ("$}{}{run%d}\n", tb->run[to]);
|
||||||
@ -482,10 +512,25 @@ latexAction (struct tracebuf *tb, int te)
|
|||||||
void
|
void
|
||||||
latexClaim (struct tracebuf *tb, int run, Termlist tl)
|
latexClaim (struct tracebuf *tb, int run, Termlist tl)
|
||||||
{
|
{
|
||||||
printf ("\\condition{$");
|
if (pass == 1)
|
||||||
printf ("\\neg secret ");
|
{
|
||||||
|
printf ("\\maxlength{\\maxmsccondition}{");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf ("\\condition{");
|
||||||
|
}
|
||||||
|
printf ("$\\neg secret ");
|
||||||
termlistPrint (tl);
|
termlistPrint (tl);
|
||||||
printf ("$}{run%d}\n", run);
|
printf ("$}");
|
||||||
|
if (pass == 1)
|
||||||
|
{
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf ("{run%d}\n", run);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -915,6 +960,41 @@ attackDisplayLatex (System sys)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Start of MSC creation (2-phase)
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* ------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* 2 pass for widths */
|
||||||
|
|
||||||
|
for (pass = 1; pass <= 2; pass++)
|
||||||
|
{
|
||||||
|
printf ("%% Pass %i\n\n",pass);
|
||||||
|
|
||||||
|
if (pass == 1)
|
||||||
|
{
|
||||||
|
printf ("\\maxlength{\\maxmscaction}{knows}\n");
|
||||||
|
printf ("\\maxlength{\\maxmscaction}{creates}\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* slightly stretch measurements */
|
||||||
|
printf ("\\addtolength{\\maxmscall}{2\\mscspacer}\n");
|
||||||
|
printf ("\\addtolength{\\maxmscaction}{\\mscspacer}\n");
|
||||||
|
printf ("\\addtolength{\\maxmscinst}{\\mscspacer}\n");
|
||||||
|
printf ("\\addtolength{\\maxmsccondition}{\\mscspacer}\n");
|
||||||
|
|
||||||
|
/* put out computed widths */
|
||||||
|
|
||||||
|
printf ("\\setlength{\\envinstdist}{0.5\\maxmscall}\n");
|
||||||
|
printf ("\\setlength{\\instdist}{\\maxmscall}\n");
|
||||||
|
printf ("\\setlength{\\actionwidth}{\\maxmscaction}\n");
|
||||||
|
printf ("\\setlength{\\instwidth}{\\maxmscinst}\n");
|
||||||
|
printf ("\\setlength{\\conditionoverlap}{0.5\\maxmsccondition}\n");
|
||||||
|
|
||||||
/* create MSC title, involving protocol names and such. */
|
/* create MSC title, involving protocol names and such. */
|
||||||
|
|
||||||
Termlist protocolnames = NULL;
|
Termlist protocolnames = NULL;
|
||||||
@ -932,6 +1012,7 @@ attackDisplayLatex (System sys)
|
|||||||
}
|
}
|
||||||
latexMSCStart (protocolnames);
|
latexMSCStart (protocolnames);
|
||||||
termlistDelete (protocolnames);
|
termlistDelete (protocolnames);
|
||||||
|
}
|
||||||
|
|
||||||
/* declare instances */
|
/* declare instances */
|
||||||
|
|
||||||
@ -941,8 +1022,11 @@ attackDisplayLatex (System sys)
|
|||||||
latexDeclInst (sys, i);
|
latexDeclInst (sys, i);
|
||||||
}
|
}
|
||||||
/* Add the intruder instance */
|
/* Add the intruder instance */
|
||||||
printf ("\\declinst{eve}{}{{\\bf Eve}: Intruder}\n");
|
if (pass == 2)
|
||||||
printf ("\n\n");
|
printf ("\\declinst{eve}{}{");
|
||||||
|
else
|
||||||
|
printf ("\\maxlength{\\maxmscinst}{");
|
||||||
|
printf ("{\\bf Eve}: Intruder}\n\n");
|
||||||
|
|
||||||
/* Print the local constants for each instance */
|
/* Print the local constants for each instance */
|
||||||
|
|
||||||
@ -960,7 +1044,10 @@ attackDisplayLatex (System sys)
|
|||||||
{
|
{
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
printf ("\\action{creates $");
|
if (pass == 1)
|
||||||
|
printf ("\\maxlength{\\maxmscaction}{$");
|
||||||
|
else
|
||||||
|
printf ("\\ActionBox{creates \\\\\n$");
|
||||||
first = 0;
|
first = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -973,6 +1060,9 @@ attackDisplayLatex (System sys)
|
|||||||
}
|
}
|
||||||
if (!first)
|
if (!first)
|
||||||
{
|
{
|
||||||
|
if (pass == 1)
|
||||||
|
printf ("$}\n");
|
||||||
|
else
|
||||||
printf ("$}{run%i}\n", i);
|
printf ("$}{run%i}\n", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -980,10 +1070,16 @@ attackDisplayLatex (System sys)
|
|||||||
|
|
||||||
/* Print the initial intruder knowledge */
|
/* Print the initial intruder knowledge */
|
||||||
|
|
||||||
printf ("\\action{knows $");
|
if (pass == 2)
|
||||||
|
{
|
||||||
|
printf ("\\ActionBox{");
|
||||||
|
printf ("knows \\\\\n$");
|
||||||
knowledgePrintLatex (tb->know[0]);
|
knowledgePrintLatex (tb->know[0]);
|
||||||
printf ("$}{eve}\n");
|
printf ("$}");
|
||||||
printf ("\\nextlevel[2]\n\n");
|
printf ("{eve}\n");
|
||||||
|
printf ("\\nextlevel[3]\n");
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* print the events in the attack */
|
/* print the events in the attack */
|
||||||
|
|
||||||
@ -1034,12 +1130,28 @@ attackDisplayLatex (System sys)
|
|||||||
{
|
{
|
||||||
/* print what was learned */
|
/* print what was learned */
|
||||||
|
|
||||||
|
if (pass == 1)
|
||||||
|
{
|
||||||
|
printf ("\\maxlength{\\maxmscaction}{");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
printf ("\\nextlevel[1]\n");
|
printf ("\\nextlevel[1]\n");
|
||||||
printf ("\\action{learns $");
|
printf ("\\ActionBox{learns \\\\\n");
|
||||||
|
}
|
||||||
|
printf ("$");
|
||||||
cKnowledge++;
|
cKnowledge++;
|
||||||
latexTermlistPrint (newtl, highlights);
|
latexTermlistPrint (newtl, highlights);
|
||||||
printf ("$}{eve}\n");
|
printf ("$}");
|
||||||
printf ("\\nextlevel[1]\n");
|
if (pass == 1)
|
||||||
|
{
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf ("{eve}\n");
|
||||||
|
printf ("\\nextlevel[2]\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
termlistDelete (highlights);
|
termlistDelete (highlights);
|
||||||
@ -1065,8 +1177,20 @@ attackDisplayLatex (System sys)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* close up diagrams
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
latexEventSpace (2);
|
latexEventSpace (2);
|
||||||
latexMSCEnd ();
|
latexMSCEnd ();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* free used memory
|
||||||
|
*/
|
||||||
|
|
||||||
memFree (runPosition, width * sizeof (int));
|
memFree (runPosition, width * sizeof (int));
|
||||||
memFree (tinfo, (tb->length + 1) * sizeof (struct traceinfo));
|
memFree (tinfo, (tb->length + 1) * sizeof (struct traceinfo));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user