1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
/*
* echoh.c - Print qdisc/class hierarchy
*
* Written 2001 by Werner Almesberger
* Copyright 2001 Network Robots
* Distributed under the LGPL.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "tccext.h"
#include "echoh.h"
static void indent(FILE *file,int level)
{
while (level--) fprintf(file," ");
}
static void force_failure(const TCCEXT_PRAGMA *pragmas,const char *location)
{
const TCCEXT_PRAGMA *p;
for (p = pragmas; p; p = p->next)
if (!strcmp(p->pragma,"force_failure")) {
fprintf(stderr,"%s: forced failure\n",location);
exit(1);
}
}
static void qdiscs(FILE *file,TCCEXT_QDISC *q,int level);
static void classes(FILE *file,TCCEXT_CLASS *c,int level)
{
while (c) {
force_failure(c->pragmas,c->location);
indent(file,level);
fprintf(file,"class %d\n",c->index);
classes(file,c->classes,level+1);
if (c->qdisc) qdiscs(file,c->qdisc,level+1);
c = c->next;
}
}
static void qdiscs(FILE *file,TCCEXT_QDISC *q,int level)
{
force_failure(q->pragmas,q->location);
indent(file,level);
fprintf(file,"qdisc %d %s\n",q->index,q->type);
classes(file,q->classes,level+1);
}
void echoh_blocks(FILE *file,TCCEXT_BLOCK *b)
{
while (b) {
force_failure(b->pragmas,b->location);
fprintf(file,"%s %sgress\n",b->name,b->role == tbr_ingress ? "in" :
"e");
qdiscs(file,b->qdiscs,1);
b = b->next;
}
}
void echoh_buckets(FILE *file,TCCEXT_BUCKET *p)
{
while (p) {
force_failure(p->pragmas,p->location);
fprintf(file,"bucket %d\n",p->index);
p = p->next;
}
}
|