~ubuntu-branches/ubuntu/maverick/ntop/maverick

« back to all changes in this revision

Viewing changes to ntop/reportUtils.c

  • Committer: Bazaar Package Importer
  • Author(s): Dennis Schoen
  • Date: 2002-04-12 11:38:47 UTC
  • Revision ID: james.westby@ubuntu.com-20020412113847-4k4yydw0pzybc6g8
Tags: upstream-2.0.0
ImportĀ upstreamĀ versionĀ 2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 1998-2001 Luca Deri <deri@ntop.org>
 
3
 *                          Portions by Stefano Suin <stefano@ntop.org>
 
4
 *
 
5
 *                          http://www.ntop.org/
 
6
 *
 
7
 *  This program is free software; you can redistribute it and/or modify
 
8
 *  it under the terms of the GNU General Public License as published by
 
9
 *  the Free Software Foundation; either version 2 of the License, or
 
10
 *  (at your option) any later version.
 
11
 *
 
12
 *  This program is distributed in the hope that it will be useful,
 
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 *  GNU General Public License for more details.
 
16
 *
 
17
 *  You should have received a copy of the GNU General Public License
 
18
 *  along with this program; if not, write to the Free Software
 
19
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
#include "ntop.h"
 
23
#include "globals-report.h"
 
24
 
 
25
/* #define PRINT_ALL_ACTIVE_SESSIONS 1  */
 
26
 
 
27
#ifndef MICRO_NTOP
 
28
 
 
29
/* ************************************ */
 
30
 
 
31
void formatUsageCounter(UsageCounter usageCtr,
 
32
                        TrafficCounter topValue
 
33
                        /* If this value != 0 then a percentage is printed */
 
34
                        ) {
 
35
  char buf[BUF_SIZE];
 
36
  int i, sendHeader=0;
 
37
 
 
38
  if(topValue == 0) {
 
39
    /* No percentage is printed */
 
40
    if(snprintf(buf, sizeof(buf), "<TD "TD_BG"  ALIGN=RIGHT>%s</TD>",
 
41
                formatPkts(usageCtr.value)) < 0)
 
42
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
43
    sendString(buf);
 
44
  } else {
 
45
    float pctg;
 
46
 
 
47
    pctg = ((float)usageCtr.value/(float)topValue)*100;
 
48
 
 
49
    if(pctg > 100) pctg = 100; /* This should not happen ! */
 
50
 
 
51
    if(snprintf(buf, sizeof(buf), "<TD "TD_BG"  ALIGN=RIGHT>%s [%.0f %%]</TD>",
 
52
                formatPkts(usageCtr.value), pctg) < 0)
 
53
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
54
    sendString(buf);
 
55
 
 
56
  }
 
57
 
 
58
  for(i=0; i<MAX_NUM_CONTACTED_PEERS; i++)
 
59
    if((usageCtr.peersIndexes[i] != NO_PEER)
 
60
       && (usageCtr.peersIndexes[i] != 0 /* Safety check: broadcast */)) {
 
61
      struct hostTraffic *el1;
 
62
 
 
63
      el1 = device[actualReportDeviceId].
 
64
       hash_hostTraffic[checkSessionIdx(usageCtr.peersIndexes[i])];
 
65
 
 
66
      if(el1 != NULL) {
 
67
       if(!sendHeader) {
 
68
         sendString("<TD "TD_BG"  ALIGN=LEFT><ul>");
 
69
         sendHeader = 1;
 
70
       }
 
71
       sendString("\n<li>");
 
72
       sendString(makeHostLink(el1, 0, 0, 0));
 
73
      }
 
74
    }
 
75
 
 
76
  if(sendHeader)
 
77
    sendString("</ul></TD>\n");
 
78
  else
 
79
    sendString("<TD "TD_BG">&nbsp;</TD>\n");
 
80
}
 
81
 
 
82
/* ********************************** */
 
83
 
 
84
void printTableDoubleEntry(char *buf, int bufLen,
 
85
                           char *label, char* color,
 
86
                           float totalS, float percentageS,
 
87
                           float totalR, float percentageR) {
 
88
  int int_perc;
 
89
 
 
90
  if((totalS == 0) && (totalR == 0)) return;
 
91
  int_perc = (int)percentageS;
 
92
 
 
93
  /* This shouldn't happen */
 
94
  if(int_perc < 0) {
 
95
    int_perc = 0;
 
96
    percentageS = 0;
 
97
  } else if(int_perc > 100) {
 
98
    int_perc = 100;
 
99
    percentageS = 100;
 
100
  }
 
101
 
 
102
  switch(int_perc) {
 
103
  case 0:
 
104
    if(snprintf(buf, bufLen, "<TR %s><TH WIDTH=100 "TH_BG" ALIGN=LEFT>%s</TH>"
 
105
           "<TD WIDTH=100 "TD_BG"  ALIGN=RIGHT>%s</TD>"
 
106
           "<TD WIDTH=100 "TD_BG">&nbsp;</TD>\n",
 
107
           getRowColor(), label, formatKBytes(totalS)) < 0)
 
108
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
109
    break;
 
110
  case 100:
 
111
    if(snprintf(buf, bufLen, "<TR %s><TH WIDTH=100 "TH_BG" ALIGN=LEFT>%s</TH>"
 
112
           "<TD WIDTH=100 "TD_BG" ALIGN=RIGHT>%s</TD>"
 
113
           "<TD WIDTH=100><IMG ALT=\"100%%\"ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=100 HEIGHT=12></TD>\n",
 
114
           getRowColor(), label, formatKBytes(totalS)) < 0)
 
115
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
116
    break;
 
117
  default:
 
118
    if(snprintf(buf, bufLen, "<TR %s><TH WIDTH=100 "TH_BG" ALIGN=LEFT>%s</TH>"
 
119
             "<TD WIDTH=100 "TD_BG"  ALIGN=RIGHT>%s</TD>"
 
120
             "<TD WIDTH=100 "TD_BG"><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"100\">"
 
121
             "<TR><TD><IMG  ALT=\"%d%%\" ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=\"%d\" HEIGHT=12></TD>"
 
122
             "<TD "TD_BG" ALIGN=CENTER WIDTH=\"%d\">"
 
123
             "<P>&nbsp;</TD></TR></TABLE></TD>\n",
 
124
             getRowColor(), label, formatKBytes(totalS),
 
125
             int_perc, (100*int_perc)/100, (100*(100-int_perc))/100) < 0)
 
126
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
127
  }
 
128
 
 
129
  sendString(buf);
 
130
 
 
131
  /* ************************ */
 
132
 
 
133
  if(totalR == 0) percentageR = 0;
 
134
 
 
135
  int_perc = (int)percentageR;
 
136
 
 
137
  /* This shouldn't happen */
 
138
  if(int_perc < 0) {
 
139
    int_perc = 0;
 
140
    percentageR = 0;
 
141
  } else if(int_perc > 100) {
 
142
    int_perc = 100;
 
143
    percentageS = 100;
 
144
  }
 
145
 
 
146
  switch(int_perc) {
 
147
  case 0:
 
148
    if(snprintf(buf, bufLen, "<TD WIDTH=100 "TD_BG"  ALIGN=RIGHT>%s</TD>"
 
149
                "<TD WIDTH=100 "TD_BG">&nbsp;</TD></TR>\n",
 
150
                formatKBytes(totalR)) < 0)
 
151
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
152
    break;
 
153
  case 100:
 
154
    if(snprintf(buf, bufLen, "<TD WIDTH=100 "TD_BG"  ALIGN=RIGHT>%s</TD>"
 
155
                "<TD WIDTH=100><IMG ALIGN=MIDDLE ALT=\"100\" SRC=/gauge.jpg WIDTH=\"100\" HEIGHT=12></TD></TR>\n",
 
156
                formatKBytes(totalR)) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
157
    break;
 
158
  default:
 
159
    if(snprintf(buf, bufLen, "<TD WIDTH=100 "TD_BG"  ALIGN=RIGHT>%s</TD>"
 
160
                "<TD  WIDTH=100 "TD_BG"><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"100\">"
 
161
                "<TR><TD><IMG ALT=\"%d%%\" ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=\"%d\" HEIGHT=12>"
 
162
                "</TD><TD "TD_BG"  ALIGN=CENTER WIDTH=\"%d\">"
 
163
                "<P>&nbsp;</TD></TR></TABLE></TD></TR>\n",
 
164
                formatKBytes(totalR),
 
165
                int_perc, (100*int_perc)/100, (100*(100-int_perc))/100) < 0)
 
166
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
167
  }
 
168
 
 
169
  sendString(buf);
 
170
}
 
171
 
 
172
/* ********************************** */
 
173
 
 
174
void printTableEntryPercentage(char *buf, int bufLen,
 
175
                               char *label, char* label_1,
 
176
                               char* label_2, float total,
 
177
                               float percentage) {
 
178
  int int_perc = (int)percentage;
 
179
 
 
180
  /* This shouldn't happen */
 
181
  if(int_perc < 0)
 
182
    int_perc = 0;
 
183
  else if(int_perc > 100)
 
184
    int_perc = 100;
 
185
 
 
186
  switch(int_perc) {
 
187
  case 0:
 
188
    if(total == -1) {
 
189
      if(snprintf(buf, bufLen, "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
190
                  "<TD ALIGN=CENTER BGCOLOR=\"%s\">%s&nbsp;(100&nbsp;%%)</TD></TR>\n",
 
191
                  getRowColor(), label, COLOR_2, label_2) < 0)
 
192
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
193
    } else {
 
194
      if(snprintf(buf, bufLen, "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>%s</TD>"
 
195
                  "<TD ALIGN=CENTER BGCOLOR=\"%s\">%s&nbsp;(100&nbsp;%%)</TD></TR>\n",
 
196
                  getRowColor(), label, formatKBytes(total), COLOR_2, label_2) < 0)
 
197
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
198
    }
 
199
    break;
 
200
  case 100:
 
201
    if(total == -1) {
 
202
      if(snprintf(buf, bufLen, "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
203
                  "<TD ALIGN=CENTER BGCOLOR=\"%s\">%s&nbsp;(100&nbsp;%%)</TD></TR>\n",
 
204
                  getRowColor(), label, COLOR_1, label_1) < 0)
 
205
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
206
    } else {
 
207
      if(snprintf(buf, bufLen, "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>%s</TD>"
 
208
                  "<TD ALIGN=CENTER BGCOLOR=\"%s\">%s&nbsp;(100&nbsp;%%)</TD></TR>\n",
 
209
                  getRowColor(), label, formatKBytes(total), COLOR_1, label_1) < 0)
 
210
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
211
    }
 
212
    break;
 
213
  default:
 
214
    if(total == -1) {
 
215
      if(snprintf(buf, bufLen, "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
216
             "<TD "TD_BG"><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"100%%\">"
 
217
             "<TR><TD ALIGN=CENTER WIDTH=\"%d%%\" BGCOLOR=\"%s\">"
 
218
             "<P>%s&nbsp;(%.1f&nbsp;%%)</TD><TD ALIGN=CENTER WIDTH=\"%d%%\" BGCOLOR=\"%s\">"
 
219
             "<P>%s&nbsp;(%.1f&nbsp;%%)</TD></TR></TABLE></TD></TR>\n",
 
220
             getRowColor(), label,
 
221
             int_perc, COLOR_1,
 
222
             label_1, percentage, (100-int_perc), COLOR_2,
 
223
             label_2, (100-percentage)) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
224
    } else {
 
225
      if(snprintf(buf, bufLen, "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>%s</TD>"
 
226
             "<TD "TD_BG"><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"100%%\">"
 
227
             "<TR><TD ALIGN=CENTER WIDTH=\"%d%%\" BGCOLOR=\"%s\">"
 
228
             "<P>%s&nbsp;(%.1f&nbsp;%%)</TD><TD ALIGN=CENTER WIDTH=\"%d%%\" BGCOLOR=\"%s\">"
 
229
             "<P>%s&nbsp;(%.1f&nbsp;%%)</TD></TR></TABLE></TD></TR>\n",
 
230
             getRowColor(), label, formatKBytes(total),
 
231
             int_perc, COLOR_1,
 
232
             label_1, percentage, (100-int_perc), COLOR_2,
 
233
                  label_2, (100-percentage)) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
234
    }
 
235
  }
 
236
 
 
237
  sendString(buf);
 
238
}
 
239
 
 
240
/* ******************************* */
 
241
 
 
242
void printHeader(int reportType, int revertOrder, u_int column) {
 
243
  char buf[BUF_SIZE];
 
244
  char *sign, *arrowGif, *arrow[48], *theAnchor[48];
 
245
  int i;
 
246
  char htmlAnchor[64], htmlAnchor1[64];
 
247
 
 
248
  /* printf("->%d<-\n",screenNumber); */
 
249
 
 
250
  if(revertOrder) {
 
251
    sign = "";
 
252
    arrowGif = "&nbsp;<IMG ALT=\"Ascending order, click to reverse\" SRC=arrow_up.gif BORDER=0>";
 
253
  } else {
 
254
    sign = "-";
 
255
    arrowGif = "&nbsp;<IMG ALT=\"Descending order, click to reverse\" SRC=arrow_down.gif BORDER=0>";
 
256
  }
 
257
 
 
258
  memset(buf, 0, sizeof(buf));
 
259
 
 
260
  if(sortSendMode) {
 
261
   if((reportType == 0) || (reportType == 1)) {
 
262
      if(reportType == 0) {
 
263
        if(snprintf(htmlAnchor, sizeof(htmlAnchor),
 
264
                    "<A HREF=/%s?%s", STR_SORT_DATA_SENT_PROTOS, sign) < 0)
 
265
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
266
        if(snprintf(htmlAnchor1, sizeof(htmlAnchor1),
 
267
                    "<A HREF=/%s?", STR_SORT_DATA_SENT_PROTOS) < 0)
 
268
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
269
      } else {
 
270
        if(snprintf(htmlAnchor, sizeof(htmlAnchor),
 
271
                    "<A HREF=/%s?%s", STR_SORT_DATA_SENT_IP, sign) < 0)
 
272
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
273
        if(snprintf(htmlAnchor1, sizeof(htmlAnchor1),
 
274
                    "<A HREF=/%s?", STR_SORT_DATA_SENT_IP) < 0)
 
275
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
276
      }
 
277
    } else if(reportType == 2) {
 
278
      if(snprintf(htmlAnchor, sizeof(htmlAnchor),
 
279
                  "<A HREF=/%s?%s",   STR_SORT_DATA_SENT_THPT, sign) < 0)
 
280
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
281
      if(snprintf(htmlAnchor1, sizeof(htmlAnchor1),
 
282
                  "<A HREF=/%s?",   STR_SORT_DATA_SENT_THPT) < 0)
 
283
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
284
    } else if(reportType == 3) {
 
285
      if(snprintf(htmlAnchor, sizeof(htmlAnchor),
 
286
                  "<A HREF=/%s?%s",   STR_SORT_DATA_SENT_HOST_TRAFFIC, sign) < 0)
 
287
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
288
      if(snprintf(htmlAnchor1, sizeof(htmlAnchor1),
 
289
                  "<A HREF=/%s?",   STR_SORT_DATA_SENT_HOST_TRAFFIC) < 0)
 
290
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
291
    }
 
292
 
 
293
    if((reportType == 0) || (reportType == 1)) {
 
294
      if(abs(column) == HOST_DUMMY_IDX_VALUE)
 
295
        { arrow[0] = arrowGif; theAnchor[0] = htmlAnchor; }
 
296
      else { arrow[0] = ""; theAnchor[0] = htmlAnchor1; }
 
297
      if(abs(column) == DOMAIN_DUMMY_IDX_VALUE)
 
298
        { arrow[1] = arrowGif; theAnchor[1] = htmlAnchor;  }
 
299
      else { arrow[1] = "";  theAnchor[1] = htmlAnchor1;}
 
300
      if(abs(column) == 0)
 
301
        { arrow[2] = arrowGif; theAnchor[2] = htmlAnchor;  }
 
302
      else { arrow[2] = ""; theAnchor[2] = htmlAnchor1; }
 
303
     sendString("<CENTER>\n");
 
304
     if(snprintf(buf, BUF_SIZE, ""TABLE_ON"<TABLE BORDER=1><TR>"
 
305
                  "<TH "TH_BG">%s"HOST_DUMMY_IDX_STR">Host%s</A></TH>\n"
 
306
                  "<TH "TH_BG">%s"DOMAIN_DUMMY_IDX_STR">Domain%s</A></TH>"
 
307
                  "<TH "TH_BG" COLSPAN=2>%s0>Sent%s</A></TH>\n",
 
308
                  theAnchor[0], arrow[0], theAnchor[1], arrow[1],
 
309
                  theAnchor[2], arrow[2]) < 0)
 
310
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
311
    } else {
 
312
      if(abs(column) == HOST_DUMMY_IDX_VALUE)
 
313
        { arrow[0] = arrowGif; theAnchor[0] = htmlAnchor; }
 
314
      else { arrow[0] = ""; theAnchor[0] = htmlAnchor1; }
 
315
      if(abs(column) == DOMAIN_DUMMY_IDX_VALUE)
 
316
        { arrow[1] = arrowGif; theAnchor[1] = htmlAnchor;  }
 
317
      else { arrow[1] = ""; theAnchor[1] = htmlAnchor1; }
 
318
      sendString("<CENTER>\n");
 
319
      if(snprintf(buf, BUF_SIZE, ""TABLE_ON"<TABLE BORDER=1><TR>"
 
320
                  "<TH "TH_BG">%s"HOST_DUMMY_IDX_STR">Host%s</A></TH>"
 
321
                  "<TH "TH_BG">%s"DOMAIN_DUMMY_IDX_STR">Domain%s</A></TH>\n\n",
 
322
                  theAnchor[0], arrow[0], theAnchor[1], arrow[1]) < 0)
 
323
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
324
    }
 
325
 
 
326
    sendString(buf);
 
327
  } else {
 
328
    if((reportType == 0) || (reportType == 1)) {
 
329
      if(reportType == 0) {
 
330
        if(snprintf(htmlAnchor, sizeof(htmlAnchor), "<A HREF=/%s?%s",
 
331
                    STR_SORT_DATA_RECEIVED_PROTOS, sign) < 0)
 
332
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
333
        if(snprintf(htmlAnchor1, sizeof(htmlAnchor1), "<A HREF=/%s?",
 
334
                    STR_SORT_DATA_RECEIVED_PROTOS) < 0)
 
335
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
336
      } else {
 
337
        if(snprintf(htmlAnchor, sizeof(htmlAnchor), "<A HREF=/%s?%s",
 
338
                    STR_SORT_DATA_RECEIVED_IP, sign) < 0)
 
339
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
340
        if(snprintf(htmlAnchor1, sizeof(htmlAnchor1), "<A HREF=/%s?",
 
341
                    STR_SORT_DATA_RECEIVED_IP) < 0)
 
342
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
343
      }
 
344
    } else if(reportType == 2) {
 
345
      if(snprintf(htmlAnchor, sizeof(htmlAnchor), "<A HREF=/%s?%s",
 
346
                  STR_SORT_DATA_RECEIVED_THPT, sign) < 0)
 
347
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
348
      if(snprintf(htmlAnchor1, sizeof(htmlAnchor1), "<A HREF=/%s?",
 
349
                  STR_SORT_DATA_RECEIVED_THPT) < 0)
 
350
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
351
    } else if(reportType == 3) {
 
352
      if(snprintf(htmlAnchor, sizeof(htmlAnchor), "<A HREF=/%s?%s",
 
353
                  STR_SORT_DATA_RCVD_HOST_TRAFFIC, sign)  < 0)
 
354
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
355
      if(snprintf(htmlAnchor1, sizeof(htmlAnchor1), "<A HREF=/%s?",
 
356
                  STR_SORT_DATA_RCVD_HOST_TRAFFIC) < 0)
 
357
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
358
    }
 
359
 
 
360
    if((reportType == 0) || (reportType == 1)) {
 
361
      if(abs(column) == HOST_DUMMY_IDX_VALUE)
 
362
        { arrow[0] = arrowGif; theAnchor[0] = htmlAnchor; }
 
363
      else { arrow[0] = ""; theAnchor[0] = htmlAnchor1; }
 
364
      if(abs(column) == DOMAIN_DUMMY_IDX_VALUE)
 
365
        { arrow[1] = arrowGif; theAnchor[1] = htmlAnchor;  }
 
366
      else { arrow[1] = "";  theAnchor[1] = htmlAnchor1;}
 
367
      if(abs(column) == 0)
 
368
        { arrow[2] = arrowGif; theAnchor[2] = htmlAnchor;  }
 
369
      else { arrow[2] = ""; theAnchor[2] = htmlAnchor1; }
 
370
      sendString("<CENTER>\n");
 
371
      if(snprintf(buf, BUF_SIZE, ""TABLE_ON"<TABLE BORDER=1><TR>"
 
372
               "<TH "TH_BG">%s"HOST_DUMMY_IDX_STR">Host%s</A></TH>\n"
 
373
              "<TH "TH_BG">%s"DOMAIN_DUMMY_IDX_STR">Domain%s</A></TH>"
 
374
              "<TH "TH_BG" COLSPAN=2>%s0>Received%s</A></TH>\n",
 
375
              theAnchor[0], arrow[0], theAnchor[1],
 
376
                  arrow[1], theAnchor[2], arrow[2]) < 0)
 
377
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
378
    } else {
 
379
      if(abs(column) == HOST_DUMMY_IDX_VALUE)
 
380
        { arrow[0] = arrowGif; theAnchor[0] = htmlAnchor; }
 
381
      else { arrow[0] = ""; theAnchor[0] = htmlAnchor1; }
 
382
      if(abs(column) == DOMAIN_DUMMY_IDX_VALUE)
 
383
        { arrow[1] = arrowGif; theAnchor[1] = htmlAnchor; }
 
384
      else { arrow[1] = ""; theAnchor[1] = htmlAnchor1;}
 
385
      sendString("<CENTER>\n");
 
386
      if(snprintf(buf, BUF_SIZE, ""TABLE_ON"<TABLE BORDER=1><TR>"
 
387
               "<TH "TH_BG">%s"HOST_DUMMY_IDX_STR">Host%s</A></TH>"
 
388
              "<TH "TH_BG">%s"DOMAIN_DUMMY_IDX_STR">Domain%s</A></TH>\n\n",
 
389
              theAnchor[0], arrow[0], theAnchor[1], arrow[1]) < 0)
 
390
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
391
    }
 
392
    sendString(buf);
 
393
  }
 
394
 
 
395
  if(reportType == 0) {
 
396
    if(abs(column) == 1)
 
397
      { arrow[0] = arrowGif; theAnchor[0] = htmlAnchor; }
 
398
    else { arrow[0] = ""; theAnchor[0] = htmlAnchor1;  }
 
399
    if(abs(column) == 2)
 
400
      { arrow[1] = arrowGif; theAnchor[1] = htmlAnchor;  }
 
401
    else { arrow[1] = "";  theAnchor[1] = htmlAnchor1;}
 
402
    if(abs(column) == 3)
 
403
      { arrow[2] = arrowGif; theAnchor[2] = htmlAnchor;  }
 
404
    else { arrow[2] = ""; theAnchor[2] = htmlAnchor1; }
 
405
    if(abs(column) == 4)
 
406
      { arrow[3] = arrowGif; theAnchor[3] = htmlAnchor;  }
 
407
    else { arrow[3] = ""; theAnchor[3] = htmlAnchor1; }
 
408
    if(abs(column) == 5)
 
409
      { arrow[4] = arrowGif; theAnchor[4] = htmlAnchor;  }
 
410
    else { arrow[4] = ""; theAnchor[4] = htmlAnchor1;  }
 
411
    if(abs(column) == 6)
 
412
      { arrow[5] = arrowGif; theAnchor[5] = htmlAnchor;  }
 
413
    else { arrow[5] = ""; theAnchor[5] = htmlAnchor1;  }
 
414
    if(abs(column) == 7)
 
415
      { arrow[6] = arrowGif; theAnchor[6] = htmlAnchor1;  }
 
416
    else { arrow[6] = ""; theAnchor[6] = htmlAnchor; }
 
417
    if(abs(column) == 8)
 
418
      { arrow[7] = arrowGif; theAnchor[7] = htmlAnchor;  }
 
419
    else { arrow[7] = ""; theAnchor[7] = htmlAnchor1;  }
 
420
    if(abs(column) == 9)
 
421
      { arrow[8] = arrowGif; theAnchor[8] = htmlAnchor;  }
 
422
    else { arrow[8] = ""; theAnchor[8] = htmlAnchor1; }
 
423
    if(abs(column) == 10)
 
424
      { arrow[9] = arrowGif; theAnchor[9] = htmlAnchor;  }
 
425
    else { arrow[9] = ""; theAnchor[9] = htmlAnchor1; }
 
426
    if(abs(column) == 11)
 
427
      { arrow[10] = arrowGif; theAnchor[10] = htmlAnchor;  }
 
428
    else { arrow[10] = "";  theAnchor[10] = htmlAnchor1;}
 
429
    if(abs(column) == 12)
 
430
      { arrow[11] = arrowGif; theAnchor[11] = htmlAnchor;  }
 
431
    else { arrow[11] = "";theAnchor[11] = htmlAnchor1; }
 
432
    if(abs(column) == 13)
 
433
      { arrow[12] = arrowGif; theAnchor[12] = htmlAnchor;  }
 
434
    else { arrow[12] = "";  theAnchor[12] = htmlAnchor1;  }
 
435
    if(abs(column) == 14)
 
436
      { arrow[13] = arrowGif; theAnchor[13] = htmlAnchor;  }
 
437
    else { arrow[13] = "";  theAnchor[13] = htmlAnchor1;  }
 
438
    if(abs(column) == 15)
 
439
      { arrow[14] = arrowGif; theAnchor[14] = htmlAnchor;  }
 
440
    else { arrow[14] = "";  theAnchor[14] = htmlAnchor1;  }
 
441
 
 
442
    if(snprintf(buf, BUF_SIZE, "<TH "TH_BG">%s1>TCP%s</A></TH>"
 
443
             "<TH "TH_BG">%s2>UDP%s</A></TH><TH "TH_BG">%s3>ICMP%s</A></TH>"
 
444
            "<TH "TH_BG">%s4>DLC%s</A></TH><TH "TH_BG">%s5>IPX%s</A>"
 
445
             "</TH><TH "TH_BG">%s6>Decnet%s</A></TH>"
 
446
             "<TH "TH_BG">%s7>(R)ARP%s</A></TH><TH "TH_BG">%s8>AppleTalk%s</A></TH>",
 
447
            theAnchor[0], arrow[0], theAnchor[1], arrow[1],
 
448
            theAnchor[2], arrow[2], theAnchor[3], arrow[3],
 
449
            theAnchor[4], arrow[4], theAnchor[5], arrow[5],
 
450
            theAnchor[6], arrow[6], theAnchor[7], arrow[7]) < 0)
 
451
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
452
    sendString(buf);
 
453
    if(snprintf(buf, BUF_SIZE,
 
454
                "<TH "TH_BG">%s9>OSPF%s</A></TH>"
 
455
                "<TH "TH_BG">%s10>NetBios%s</A></TH>"
 
456
                "<TH "TH_BG">%s11>IGMP%s</A></TH>"
 
457
                "<TH "TH_BG">%s12>OSI%s</A></TH>"
 
458
                "<TH "TH_BG">%s13>QNX%s</A></TH>"
 
459
                "<TH "TH_BG">%s14>STP%s</A></TH>"
 
460
                "<TH "TH_BG">%s15>Other%s</A></TH>",
 
461
                theAnchor[8], arrow[8],
 
462
                theAnchor[9], arrow[9],
 
463
                theAnchor[10], arrow[10],
 
464
                theAnchor[11], arrow[11],
 
465
                theAnchor[12], arrow[12],
 
466
                theAnchor[13], arrow[13],
 
467
                theAnchor[14], arrow[14]) < 0)
 
468
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
469
    sendString(buf);
 
470
  } else if(reportType == 1) {
 
471
    int soFar=2;
 
472
 
 
473
    if(abs(column) == 1) {
 
474
        arrow[0] = arrowGif;
 
475
        theAnchor[0] = htmlAnchor;
 
476
      } else {
 
477
        arrow[0] = "";
 
478
        theAnchor[0] = htmlAnchor1;
 
479
      }
 
480
 
 
481
#ifdef ENABLE_NAPSTER
 
482
    if(snprintf(buf, BUF_SIZE, "<TH "TH_BG">%s%d>%s%s</A></TH>",
 
483
                theAnchor[0], 1, "Napster", arrow[0]) < 0)
 
484
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
485
    sendString(buf);
 
486
#endif
 
487
 
 
488
    for(i=0; i<numIpProtosToMonitor; i++) {
 
489
      if(abs(column) == soFar) {
 
490
        arrow[0] = arrowGif;
 
491
        theAnchor[0] = htmlAnchor;
 
492
      } else {
 
493
        arrow[0] = "";
 
494
        theAnchor[0] = htmlAnchor1;
 
495
      }
 
496
      if(snprintf(buf, BUF_SIZE, "<TH "TH_BG">%s%d>%s%s</A></TH>",
 
497
              theAnchor[0], i+2, protoIPTrafficInfos[i], arrow[0]) < 0)
 
498
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
499
      sendString(buf);
 
500
      soFar++;
 
501
    }
 
502
 
 
503
    if(abs(column) == soFar) {
 
504
      arrow[0] = arrowGif; theAnchor[0] = htmlAnchor;
 
505
    } else {
 
506
      arrow[0] = "";  theAnchor[0] = htmlAnchor1;
 
507
    }
 
508
    if(snprintf(buf, BUF_SIZE, "<TH "TH_BG">%s%d>Other&nbsp;IP%s</A></TH>",
 
509
             theAnchor[0], i+2, arrow[0]) < 0)
 
510
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
511
    sendString(buf);
 
512
  } else if(reportType == 2) {
 
513
    updateThpt();
 
514
    if(abs(column) == 1) { arrow[0] = arrowGif; theAnchor[0] = htmlAnchor; }
 
515
    else { arrow[0] = ""; theAnchor[0] = htmlAnchor1;  }
 
516
    if(abs(column) == 2) { arrow[1] = arrowGif; theAnchor[1] = htmlAnchor; }
 
517
    else { arrow[1] = ""; theAnchor[1] = htmlAnchor1; }
 
518
    if(abs(column) == 3) { arrow[2] = arrowGif; theAnchor[2] = htmlAnchor; }
 
519
    else { arrow[2] = "";  theAnchor[2] = htmlAnchor1;}
 
520
    if(abs(column) == 4) { arrow[3] = arrowGif; theAnchor[3] = htmlAnchor; }
 
521
    else { arrow[3] = "";  theAnchor[3] = htmlAnchor1;}
 
522
    if(abs(column) == 5) { arrow[4] = arrowGif; theAnchor[4] = htmlAnchor; }
 
523
    else { arrow[4] = "";  theAnchor[4] = htmlAnchor1;}
 
524
    if(abs(column) == 6) { arrow[5] = arrowGif; theAnchor[5] = htmlAnchor; }
 
525
    else { arrow[5] = "";  theAnchor[5] = htmlAnchor1;}
 
526
 
 
527
    if(snprintf(buf, BUF_SIZE, "<TH "TH_BG">%s1>Actual Thpt%s</A></TH>"
 
528
             "<TH "TH_BG">%s2>Avg Thpt%s</A></TH>"
 
529
             "<TH "TH_BG">%s3>Peak Thpt%s</A></TH>"
 
530
            "<TH "TH_BG">%s4>Actual Pkt Thpt%s</A></TH><TH "TH_BG">%s5>Avg Pkt Thpt%s</A></TH>"
 
531
             "<TH "TH_BG">%s6>Peak Pkt Thpt%s</A></TH>",
 
532
            theAnchor[0], arrow[0], theAnchor[1], arrow[1], theAnchor[2], arrow[2],
 
533
            theAnchor[3], arrow[3], theAnchor[4], arrow[4], theAnchor[5], arrow[5]) < 0)
 
534
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
535
    sendString(buf);
 
536
  } else if(reportType == 3) {
 
537
    sendString("<TH "TH_BG">0<br>AM</TH><TH "TH_BG">1<br>AM</TH>"
 
538
               "<TH "TH_BG">2<br>AM</TH><TH "TH_BG">3<br>AM</TH>"
 
539
               "<TH "TH_BG">4<br>AM</TH><TH "TH_BG">5<br>AM</TH><TH "TH_BG">6<br>AM</TH>"
 
540
               "<TH "TH_BG">7<br>AM</TH><TH "TH_BG">8<br>AM</TH><TH "TH_BG">9<br>AM</TH>"
 
541
               "<TH "TH_BG">10<br>AM</TH><TH "TH_BG">11<br>AM</TH><TH "TH_BG">12<br>AM</TH>\n");
 
542
    sendString("<TH "TH_BG">1<br>PM</TH><TH "TH_BG">2<br>PM</TH><TH "TH_BG">3<br>PM</TH>"
 
543
               "<TH "TH_BG">4<br>PM</TH><TH "TH_BG">5<br>PM</TH><TH "TH_BG">6<br>PM</TH>"
 
544
               "<TH "TH_BG">7<br>PM</TH><TH "TH_BG">8<br>PM</TH><TH "TH_BG">9<br>PM</TH>"
 
545
               "<TH "TH_BG">10<br>PM</TH><TH "TH_BG">11<br>PM</TH>\n");
 
546
  }
 
547
  sendString("</TR>\n");
 
548
}
 
549
 
 
550
/* ******************************* */
 
551
 
 
552
char* getOSFlag(char* osName, int showOsName) {
 
553
  static char tmpStr[96], *flagImg;
 
554
 
 
555
  if(strstr(osName, "Windows") != NULL)
 
556
    flagImg = "<IMG ALT=\"OS: Windows\" ALIGN=MIDDLE SRC=/statsicons/os/windows.gif>";
 
557
  else if(strstr(osName, "IRIX") != NULL)
 
558
    flagImg = "<IMG ALT=\"OS: Irix\" ALIGN=MIDDLE SRC=/statsicons/os/irix.gif>";
 
559
  else if(strstr(osName, "Linux") != NULL)
 
560
    flagImg = "<IMG ALT=\"OS: Linux\" ALIGN=MIDDLE SRC=/statsicons/os/linux.gif>";
 
561
  else if(strstr(osName, "SunOS") != NULL)
 
562
    flagImg = "<IMG  ALT=\"OS: SunOS\" ALIGN=MIDDLE SRC=/statsicons/os/sun.gif>";
 
563
  else if(strstr(osName, "Solaris") != NULL)
 
564
    flagImg = "<IMG  ALT=\"OS: Solaris\" ALIGN=MIDDLE SRC=/statsicons/os/sun.gif>";
 
565
  else if(strstr(osName, "HP/JETdirect") != NULL)
 
566
    flagImg = "<IMG  ALT=\"OS: HP/JetDirect\" ALIGN=MIDDLE SRC=/statsicons/os/hp.gif>";
 
567
  else if(strstr(osName, "Mac") != NULL)
 
568
    flagImg = "<IMG  ALT=\"OS: Apple Mac\" ALIGN=MIDDLE SRC=/statsicons/os/mac.gif>";
 
569
  else if(strstr(osName, "Novell") != NULL)
 
570
    flagImg = "<IMG ALT=\"OS: Novell\" ALIGN=MIDDLE SRC=/statsicons/os/novell.gif>";
 
571
  else if((strstr(osName, "BSD") != NULL) 
 
572
          || (strstr(osName, "Unix") != NULL)
 
573
          || (strstr(osName, "Berkeley") != NULL))
 
574
    flagImg = "<IMG ALT=\"OS: BSD Unix\" ALIGN=MIDDLE SRC=/statsicons/os/bsd.gif>";
 
575
  else if(strstr(osName, "HP-UX") != NULL)
 
576
    flagImg = "<IMG ALT=\"OS: HP-UX\" ALIGN=MIDDLE SRC=/statsicons/os/hp.gif>";
 
577
  else if(strstr(osName, "AIX") != NULL)
 
578
    flagImg = "<IMG ALT=\"OS: AIX\" ALIGN=MIDDLE SRC=/statsicons/os/aix.gif>";
 
579
  else
 
580
    flagImg = NULL;
 
581
 
 
582
  if(!showOsName) {
 
583
    if(flagImg != NULL)
 
584
      strncpy(tmpStr, flagImg, sizeof(tmpStr));
 
585
    else
 
586
      strncpy(tmpStr, "", sizeof(tmpStr));
 
587
  } else {
 
588
    if(flagImg != NULL) {
 
589
      if(snprintf(tmpStr, sizeof(tmpStr), "%s&nbsp;[%s]", flagImg, osName) < 0)
 
590
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
591
    } else
 
592
      strncpy(tmpStr, osName, sizeof(tmpStr));
 
593
  }
 
594
 
 
595
  return(tmpStr);
 
596
}
 
597
 
 
598
/* ******************************* */
 
599
 
 
600
int sortHostFctn(const void *_a, const void *_b) {
 
601
  HostTraffic **a = (HostTraffic **)_a;
 
602
  HostTraffic **b = (HostTraffic **)_b;
 
603
  int rc;
 
604
  char *nameA, *nameB, nameA_str[32], nameB_str[32];
 
605
 
 
606
  if((a == NULL) && (b != NULL)) {
 
607
    traceEvent(TRACE_WARNING, "WARNING (1)\n");
 
608
    return(1);
 
609
  } else if((a != NULL) && (b == NULL)) {
 
610
    traceEvent(TRACE_WARNING, "WARNING (2)\n");
 
611
    return(-1);
 
612
  } else if((a == NULL) && (b == NULL)) {
 
613
    traceEvent(TRACE_WARNING, "WARNING (3)\n");
 
614
    return(0);
 
615
  }
 
616
 
 
617
  switch(columnSort) {
 
618
  case 1:
 
619
#ifdef MULTITHREADED
 
620
    accessMutex(&addressResolutionMutex, "sortHostFctn");
 
621
#endif
 
622
    rc = strcasecmp((*a)->hostSymIpAddress[0] != '\0' ? (*a)->hostSymIpAddress : (*a)->ethAddressString,
 
623
                    (*b)->hostSymIpAddress[0] != '\0' ? (*b)->hostSymIpAddress : (*b)->ethAddressString);
 
624
#ifdef MULTITHREADED
 
625
    releaseMutex(&addressResolutionMutex);
 
626
#endif
 
627
    return(rc);
 
628
    break;
 
629
  case 2:
 
630
    if((*a)->hostIpAddress.s_addr > (*b)->hostIpAddress.s_addr)
 
631
      return(1);
 
632
    else if((*a)->hostIpAddress.s_addr < (*b)->hostIpAddress.s_addr)
 
633
      return(-1);
 
634
    else
 
635
      return(0);
 
636
    /* return(strcasecmp((*a)->hostNumIpAddress, (*b)->hostNumIpAddress)); */
 
637
    break;
 
638
  case 3:
 
639
    return(strcasecmp((*a)->ethAddressString, (*b)->ethAddressString));
 
640
    break;
 
641
  case 5:
 
642
    return(strcasecmp(getVendorInfo((*a)->ethAddress, 0),
 
643
                      getVendorInfo((*b)->ethAddress, 0)));
 
644
    break;
 
645
  case 6:
 
646
    if((*a)->nbHostName != NULL)
 
647
      nameA = (*a)->nbHostName;
 
648
    else if((*a)->atNodeName != NULL)
 
649
      nameA = (*a)->atNodeName;
 
650
    else if((*a)->atNetwork != 0) {
 
651
      if(snprintf(nameA_str, sizeof(nameA_str), "%d.%d", (*a)->atNetwork, (*a)->atNode) < 0)
 
652
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
653
      nameA = nameA_str;
 
654
    } else if((*a)->ipxHostName != NULL)
 
655
      nameA = (*a)->ipxHostName;
 
656
    else
 
657
      nameA = "";
 
658
 
 
659
    if((*b)->nbHostName != NULL)
 
660
      nameB = (*b)->nbHostName;
 
661
    else if((*b)->atNodeName != NULL)
 
662
      nameB = (*b)->atNodeName;
 
663
    else if((*a)->atNetwork != 0) {
 
664
      if(snprintf(nameB_str, sizeof(nameB_str), "%d.%d", (*b)->atNetwork, (*b)->atNode) < 0)
 
665
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
666
      nameB = nameB_str;
 
667
    } else if((*b)->ipxHostName != NULL)
 
668
      nameB = (*b)->ipxHostName;
 
669
    else
 
670
      nameB = "";
 
671
 
 
672
    return(strcasecmp(nameA, nameB));
 
673
    break;
 
674
  case 4:
 
675
  default:
 
676
    if((*a)->actBandwidthUsage < (*b)->actBandwidthUsage)
 
677
      return(1);
 
678
    else if ((*a)->actBandwidthUsage > (*b)->actBandwidthUsage)
 
679
      return(-1);
 
680
    else
 
681
      return(0);
 
682
    break;
 
683
  }
 
684
}
 
685
 
 
686
/* ******************************* */
 
687
 
 
688
int cmpUsersTraffic(const void *_a, const void *_b) {
 
689
  UsersTraffic **a = (UsersTraffic **)_a;
 
690
  UsersTraffic **b = (UsersTraffic **)_b;
 
691
  TrafficCounter sum_a, sum_b;
 
692
 
 
693
  if((a == NULL) && (b != NULL)) {
 
694
    return(1);
 
695
  } else if((a != NULL) && (b == NULL)) {
 
696
    return(-1);
 
697
  } else if((a == NULL) && (b == NULL)) {
 
698
    return(0);
 
699
  }
 
700
 
 
701
  sum_a = (*a)->bytesSent + (*a)->bytesReceived;
 
702
  sum_b = (*b)->bytesSent + (*b)->bytesReceived;
 
703
 
 
704
  if(sum_a > sum_b)
 
705
    return(-1);
 
706
  else if (sum_a == sum_b)
 
707
    return(0);
 
708
  else
 
709
    return(1);
 
710
}
 
711
 
 
712
/* ******************************* */
 
713
 
 
714
int cmpProcesses(const void *_a, const void *_b) {
 
715
  ProcessInfo **a = (ProcessInfo **)_a;
 
716
  ProcessInfo **b = (ProcessInfo **)_b;
 
717
 
 
718
  if((a == NULL) && (b != NULL)) {
 
719
    return(1);
 
720
  } else if((a != NULL) && (b == NULL)) {
 
721
    return(-1);
 
722
  } else if((a == NULL) && (b == NULL)) {
 
723
    return(0);
 
724
  }
 
725
 
 
726
  switch(columnSort) {
 
727
  case 2: /* PID */
 
728
    if((*a)->pid == (*b)->pid)
 
729
      return(0);
 
730
    else if((*a)->pid < (*b)->pid)
 
731
      return(1);
 
732
    else return(-1);
 
733
    break;
 
734
  case 3: /* User */
 
735
    return(strcasecmp((*a)->user, (*b)->user));
 
736
    break;
 
737
  case 4: /* Sent */
 
738
    if((*a)->bytesSent == (*b)->bytesSent)
 
739
      return(0);
 
740
    else if((*a)->bytesSent < (*b)->bytesSent)
 
741
      return(1);
 
742
    else return(-1);
 
743
    break;
 
744
  case 5: /* Rcvd */
 
745
    if((*a)->bytesReceived == (*b)->bytesReceived)
 
746
      return(0);
 
747
    else if((*a)->bytesReceived < (*b)->bytesReceived)
 
748
      return(1);
 
749
    else return(-1);
 
750
    break;
 
751
  default: /* Process name */
 
752
    return(strcasecmp((*a)->command, (*b)->command));
 
753
  }
 
754
}
 
755
 
 
756
/* ******************************* */
 
757
 
 
758
int cmpFctn(const void *_a, const void *_b) {
 
759
  HostTraffic **a = (HostTraffic **)_a;
 
760
  HostTraffic **b = (HostTraffic **)_b;
 
761
  TrafficCounter a_=0, b_=0;
 
762
  float fa_=0, fb_=0;
 
763
  int idx;
 
764
  short oldColumnSort, floatCompare=0;
 
765
 
 
766
  if((a == NULL) && (b != NULL)) {
 
767
    traceEvent(TRACE_WARNING, "WARNING (1)\n");
 
768
    return(1);
 
769
  } else if((a != NULL) && (b == NULL)) {
 
770
    traceEvent(TRACE_WARNING, "WARNING (2)\n");
 
771
    return(-1);
 
772
  } else if((a == NULL) && (b == NULL)) {
 
773
    traceEvent(TRACE_WARNING, "WARNING (3)\n");
 
774
    return(0);
 
775
  }
 
776
 
 
777
#ifdef DEBUG
 
778
  printf("screenNumber=%d, columnSort=%d\n", screenNumber, columnSort);
 
779
#endif
 
780
 
 
781
  if(columnSort == HOST_DUMMY_IDX_VALUE) {
 
782
    int rc;
 
783
 
 
784
    /* Host name */
 
785
#ifdef MULTITHREADED
 
786
    accessMutex(&addressResolutionMutex, "cmpFctn");
 
787
#endif
 
788
 
 
789
    if((*a)->hostSymIpAddress[0] != '\0') {
 
790
      char *name1, *name2;
 
791
 
 
792
      name1 = (*a)->hostSymIpAddress;
 
793
      name2 = (*b)->hostSymIpAddress;
 
794
 
 
795
      if(name1[0] == '*') name1++;
 
796
      if(name2[0] == '*') name2++;
 
797
      rc = strcasecmp(name1, name2);
 
798
    } else
 
799
      rc = strcasecmp((*a)->ethAddressString, (*b)->ethAddressString);
 
800
 
 
801
#ifdef MULTITHREADED
 
802
    releaseMutex(&addressResolutionMutex);
 
803
#endif
 
804
    return(rc);
 
805
  } else if(columnSort == DOMAIN_DUMMY_IDX_VALUE) {
 
806
    int rc;
 
807
 
 
808
    fillDomainName(*a); fillDomainName(*b);
 
809
 
 
810
#ifdef DEBUG
 
811
    traceEvent(TRACE_INFO, "%s='%s'/'%s' - %s='%s'/'%s'\n",
 
812
           (*a)->hostSymIpAddress,
 
813
           (*a)->dotDomainName, (*a)->fullDomainName,
 
814
           (*b)->hostSymIpAddress,
 
815
           (*b)->dotDomainName, (*b)->fullDomainName
 
816
           );
 
817
#endif
 
818
    rc = strcasecmp((*a)->dotDomainName, (*b)->dotDomainName);
 
819
    if(rc == 0)
 
820
      return(strcasecmp((*a)->fullDomainName, (*b)->fullDomainName));
 
821
    else
 
822
      return rc;
 
823
  }
 
824
 
 
825
  oldColumnSort = columnSort;
 
826
 
 
827
  if(screenNumber == DUMMY_IDX_VALUE) {
 
828
    /* dirty trick */
 
829
    idx = columnSort-1;
 
830
    if(idx == -1) {
 
831
      idx = 0;
 
832
      columnSort = 0;
 
833
    } else
 
834
      columnSort = 1;
 
835
  } else
 
836
    idx = (screenNumber-MAX_NUM_PROTOS_SCREENS)*3;
 
837
 
 
838
#ifdef DEBUG
 
839
  traceEvent(TRACE_INFO, "idx=%d/columnSort=%d/sortSendMode=%d/screenNumber=%d/numIpProtosToMonitor=%d\n",
 
840
         idx, columnSort, sortSendMode, screenNumber, numIpProtosToMonitor);
 
841
#endif
 
842
 
 
843
  switch(columnSort) {
 
844
  case 0:
 
845
    if(sortSendMode) {
 
846
      a_ = (*a)->bytesSent, b_ = (*b)->bytesSent;
 
847
    } else {
 
848
      a_ = (*a)->bytesReceived, b_ = (*b)->bytesReceived;
 
849
    }
 
850
    break;
 
851
  case 1:
 
852
    if(sortSendMode) {
 
853
      switch(screenNumber)
 
854
        {
 
855
        case 0:
 
856
          a_ = (*a)->tcpSentLocally+(*a)->tcpSentRemotely;
 
857
          b_ = (*b)->tcpSentLocally+(*b)->tcpSentRemotely;
 
858
          break;
 
859
        case 1:
 
860
          a_ = (*a)->dlcSent, b_ = (*b)->dlcSent;
 
861
          break;
 
862
        case 2:
 
863
          a_ = (*a)->arp_rarpSent, b_ = (*b)->arp_rarpSent;
 
864
          break;
 
865
        case 3:
 
866
          a_ = (*a)->netbiosSent, b_ = (*b)->netbiosSent;
 
867
          break;
 
868
        case MAX_NUM_PROTOS_SCREENS:
 
869
          fa_ = (*a)->actualSentThpt, fb_ = (*b)->actualSentThpt, floatCompare = 1;
 
870
          break;
 
871
        default:
 
872
 
 
873
          if(idx <= numIpProtosToMonitor) {
 
874
            if(idx == 0) {
 
875
#ifdef ENABLE_NAPSTER
 
876
              if((*a)->napsterStats == NULL)
 
877
                a_ = 0;
 
878
              else
 
879
                a_ = (*a)->napsterStats->bytesSent;
 
880
 
 
881
              if((*b)->napsterStats == NULL)
 
882
                b_ = 0;
 
883
              else
 
884
                b_ = (*b)->napsterStats->bytesSent;
 
885
#else
 
886
              a_ = b_ = 0;
 
887
#endif
 
888
            } else {
 
889
              a_ = (*a)->protoIPTrafficInfos[idx-1].sentLocally
 
890
                +(*a)->protoIPTrafficInfos[idx-1].sentRemotely;
 
891
              b_ = (*b)->protoIPTrafficInfos[idx-1].sentLocally
 
892
                +(*b)->protoIPTrafficInfos[idx-1].sentRemotely;
 
893
            }
 
894
          } else {
 
895
            int i;
 
896
 
 
897
            a_ = 0, b_ = 0;
 
898
 
 
899
            for(i=0; i<numIpProtosToMonitor; i++) {
 
900
              a_ += (*a)->protoIPTrafficInfos[i].sentLocally
 
901
                +(*a)->protoIPTrafficInfos[i].sentRemotely;
 
902
              b_ += (*b)->protoIPTrafficInfos[i].sentLocally
 
903
                +(*b)->protoIPTrafficInfos[i].sentRemotely;
 
904
            }
 
905
 
 
906
            if((*a)->bytesSent > a_)
 
907
              a_ = (*a)->bytesSent-a_;
 
908
            else
 
909
              a_ = 0;
 
910
 
 
911
            if((*b)->bytesSent > b_)
 
912
              b_ = (*b)->bytesSent-b_;
 
913
            else
 
914
              b_ = 0;
 
915
          }
 
916
        }
 
917
    } else {
 
918
      switch(screenNumber)
 
919
        {
 
920
        case 0:
 
921
          a_ = (*a)->tcpReceivedLocally+(*a)->tcpReceivedFromRemote;
 
922
          b_ = (*b)->tcpReceivedLocally+(*b)->tcpReceivedFromRemote;
 
923
          break;
 
924
        case 1:
 
925
          a_ = (*a)->dlcReceived, b_ = (*b)->dlcReceived;
 
926
          break;
 
927
        case 2:
 
928
          a_ = (*a)->arp_rarpReceived, b_ = (*b)->arp_rarpReceived;
 
929
          break;
 
930
        case 3:
 
931
          a_ = (*a)->netbiosReceived, b_ = (*b)->netbiosReceived;
 
932
          break;
 
933
        case MAX_NUM_PROTOS_SCREENS:
 
934
          fa_ = (*a)->actualRcvdThpt,
 
935
            fb_ = (*b)->actualRcvdThpt, floatCompare = 1;
 
936
          break;
 
937
        default:
 
938
          if(idx <= numIpProtosToMonitor) {
 
939
            if(idx == 0) {
 
940
#ifdef ENABLE_NAPSTER
 
941
              if((*a)->napsterStats == NULL)
 
942
                a_ = 0;
 
943
              else
 
944
                a_ = (*a)->napsterStats->bytesRcvd;
 
945
 
 
946
              if((*b)->napsterStats == NULL)
 
947
                b_ = 0;
 
948
              else
 
949
                b_ = (*b)->napsterStats->bytesRcvd;
 
950
#else
 
951
              a_ = b_ = 0;
 
952
#endif
 
953
            } else {
 
954
              a_ = (*a)->protoIPTrafficInfos[idx-1].receivedLocally
 
955
                +(*a)->protoIPTrafficInfos[idx-1].receivedFromRemote;
 
956
              b_ = (*b)->protoIPTrafficInfos[idx-1].receivedLocally
 
957
                +(*b)->protoIPTrafficInfos[idx-1].receivedFromRemote;
 
958
            }
 
959
          } else {
 
960
            int i;
 
961
 
 
962
            a_ = 0, b_ = 0;
 
963
 
 
964
            for(i=0; i<numIpProtosToMonitor; i++) {
 
965
              a_ += (*a)->protoIPTrafficInfos[i].receivedLocally
 
966
                +(*a)->protoIPTrafficInfos[i].receivedFromRemote;
 
967
              b_ += (*b)->protoIPTrafficInfos[i].receivedLocally
 
968
                +(*b)->protoIPTrafficInfos[i].receivedFromRemote;
 
969
            }
 
970
 
 
971
            if((*a)->bytesReceived > a_)
 
972
              a_ = (*a)->bytesReceived-a_;
 
973
            else
 
974
              a_ = 0;
 
975
 
 
976
            if((*b)->bytesReceived > b_)
 
977
              b_ = (*b)->bytesReceived-b_;
 
978
            else
 
979
              b_ = 0;
 
980
 
 
981
            /*
 
982
              traceEvent(TRACE_INFO, "=>%d (%s)<=>%d (%s)<=\n",
 
983
              (int)a_, (*a)->hostSymIpAddress,
 
984
              (int)b_, (*b)->hostSymIpAddress);
 
985
            */
 
986
          }
 
987
        }
 
988
    }
 
989
    break;
 
990
  case 2:
 
991
    if(sortSendMode) {
 
992
      switch(screenNumber)
 
993
        {
 
994
        case 0:
 
995
          a_ = (*a)->udpSentLocally +(*a)->udpSentRemotely;
 
996
          b_ = (*b)->udpSentLocally +(*b)->udpSentRemotely;
 
997
          break;
 
998
        case 1:
 
999
          a_ = (*a)->ipxSent, b_ = (*b)->ipxSent;
 
1000
          break;
 
1001
        case 2:
 
1002
          a_ = (*a)->appletalkSent, b_ = (*b)->appletalkSent;
 
1003
          break;
 
1004
        case 3:
 
1005
          a_ = (*a)->igmpSent, b_ = (*b)->igmpSent;
 
1006
          break;
 
1007
        case MAX_NUM_PROTOS_SCREENS:
 
1008
          fa_ = (*a)->averageSentThpt,
 
1009
            fb_ = (*b)->averageSentThpt, floatCompare = 1;
 
1010
          break;
 
1011
        default:
 
1012
          if(++idx < numIpProtosToMonitor) {
 
1013
            a_ = (*a)->protoIPTrafficInfos[idx].sentLocally
 
1014
              +(*a)->protoIPTrafficInfos[idx].sentRemotely;
 
1015
            b_ = (*b)->protoIPTrafficInfos[idx].sentLocally
 
1016
              +(*b)->protoIPTrafficInfos[idx].sentRemotely;
 
1017
          } else {
 
1018
            int i;
 
1019
 
 
1020
            a_ = 0, b_ = 0;
 
1021
 
 
1022
            for(i=0; i<numIpProtosToMonitor; i++) {
 
1023
              a_ += (*a)->protoIPTrafficInfos[i].sentLocally
 
1024
                +(*a)->protoIPTrafficInfos[i].sentRemotely;
 
1025
              b_ += (*b)->protoIPTrafficInfos[i].sentLocally
 
1026
                +(*b)->protoIPTrafficInfos[i].sentRemotely;
 
1027
            }
 
1028
 
 
1029
            if((*a)->bytesSent > a_)
 
1030
              a_ = (*a)->bytesSent-a_;
 
1031
            else
 
1032
              a_ = 0;
 
1033
 
 
1034
            if((*b)->bytesSent > b_)
 
1035
              b_ = (*b)->bytesSent-b_;
 
1036
            else
 
1037
              b_ = 0;
 
1038
          }
 
1039
        }
 
1040
    } else {
 
1041
      switch(screenNumber)
 
1042
        {
 
1043
        case 0:
 
1044
          a_ = (*a)->udpReceivedLocally +(*a)->udpReceivedFromRemote;
 
1045
          b_ = (*b)->udpReceivedLocally +(*b)->udpReceivedFromRemote;
 
1046
          break;
 
1047
        case 1:
 
1048
          a_ = (*a)->ipxReceived, b_ = (*b)->ipxReceived;
 
1049
          break;
 
1050
        case 2:
 
1051
          a_ = (*a)->appletalkReceived, b_ = (*b)->appletalkReceived;
 
1052
          break;
 
1053
        case 3:
 
1054
          a_ = (*a)->igmpReceived, b_ = (*b)->igmpReceived;
 
1055
          break;
 
1056
        case MAX_NUM_PROTOS_SCREENS:
 
1057
          fa_ = (*a)->averageRcvdThpt,
 
1058
            fb_ = (*b)->averageRcvdThpt, floatCompare = 1;
 
1059
          break;
 
1060
        default:
 
1061
          if(++idx < numIpProtosToMonitor) {
 
1062
            a_ = (*a)->protoIPTrafficInfos[idx].receivedLocally
 
1063
              +(*a)->protoIPTrafficInfos[idx].receivedFromRemote;
 
1064
            b_ = (*b)->protoIPTrafficInfos[idx].receivedLocally
 
1065
              +(*b)->protoIPTrafficInfos[idx].receivedFromRemote;
 
1066
          } else {
 
1067
            int i;
 
1068
 
 
1069
            a_ = 0, b_ = 0;
 
1070
 
 
1071
            for(i=0; i<numIpProtosToMonitor; i++) {
 
1072
              a_ += (*a)->protoIPTrafficInfos[i].receivedLocally
 
1073
                +(*a)->protoIPTrafficInfos[i].receivedFromRemote;
 
1074
              b_ += (*b)->protoIPTrafficInfos[i].receivedLocally
 
1075
                +(*b)->protoIPTrafficInfos[i].receivedFromRemote;
 
1076
            }
 
1077
 
 
1078
            if((*a)->bytesReceived > a_)
 
1079
              a_ = (*a)->bytesReceived-a_;
 
1080
            else
 
1081
              a_ = 0;
 
1082
 
 
1083
            if((*b)->bytesReceived > b_)
 
1084
              b_ = (*b)->bytesReceived-b_;
 
1085
            else
 
1086
              b_ = 0;
 
1087
          }
 
1088
        }
 
1089
    }
 
1090
    break;
 
1091
  case 3:
 
1092
    if(sortSendMode) {
 
1093
      switch(screenNumber)
 
1094
        {
 
1095
        case 0:
 
1096
          a_ = (*a)->icmpSent, b_ = (*b)->icmpSent;
 
1097
          break;
 
1098
        case 1:
 
1099
          a_ = (*a)->decnetSent, b_ = (*b)->decnetSent;
 
1100
          break;
 
1101
        case 2:
 
1102
          a_ = (*a)->ospfSent, b_ = (*b)->ospfSent;
 
1103
          break;
 
1104
        case 3:
 
1105
          a_ = (*a)->osiSent, b_ = (*b)->osiSent;
 
1106
          break;
 
1107
        case 4:
 
1108
          a_ = (*a)->qnxSent, b_ = (*b)->qnxSent;
 
1109
          break;
 
1110
        case 5: /* MAX_NUM_PROTOS_SCREENS: */
 
1111
          fa_ = (*a)->peakSentThpt,
 
1112
            fb_ = (*b)->peakSentThpt, floatCompare = 1;
 
1113
          break;
 
1114
        default:
 
1115
          idx+=2;
 
1116
          if(idx < numIpProtosToMonitor) {
 
1117
            a_ = (*a)->protoIPTrafficInfos[idx].sentLocally
 
1118
              +(*a)->protoIPTrafficInfos[idx].sentRemotely;
 
1119
            b_ = (*b)->protoIPTrafficInfos[idx].sentLocally
 
1120
              +(*b)->protoIPTrafficInfos[idx].sentRemotely;
 
1121
          } else {
 
1122
            int i;
 
1123
 
 
1124
            a_ = 0, b_ = 0;
 
1125
 
 
1126
            for(i=0; i<numIpProtosToMonitor; i++) {
 
1127
              a_ += (*a)->protoIPTrafficInfos[i].sentLocally
 
1128
                +(*a)->protoIPTrafficInfos[i].sentRemotely;
 
1129
              b_ += (*b)->protoIPTrafficInfos[i].sentLocally
 
1130
                +(*b)->protoIPTrafficInfos[i].sentRemotely;
 
1131
            }
 
1132
 
 
1133
            if((*a)->bytesSent > a_)
 
1134
              a_ = (*a)->bytesSent-a_;
 
1135
            else
 
1136
              a_ = 0;
 
1137
 
 
1138
            if((*b)->bytesSent > b_)
 
1139
              b_ = (*b)->bytesSent-b_;
 
1140
            else
 
1141
              b_ = 0;
 
1142
          }
 
1143
        }
 
1144
    } else {
 
1145
      switch(screenNumber)
 
1146
        {
 
1147
        case 0:
 
1148
          a_ = (*a)->icmpReceived, b_ = (*b)->icmpReceived;
 
1149
          break;
 
1150
        case 1:
 
1151
          a_ = (*a)->decnetReceived, b_ = (*b)->decnetReceived;
 
1152
          break;
 
1153
        case 2:
 
1154
          a_ = (*a)->ospfReceived, b_ = (*b)->ospfReceived;
 
1155
          break;
 
1156
        case 3:
 
1157
          a_ = (*a)->osiReceived, b_ = (*b)->osiReceived;
 
1158
          break;
 
1159
        case MAX_NUM_PROTOS_SCREENS:
 
1160
          fa_ = (*a)->peakRcvdThpt,
 
1161
            fb_ = (*b)->peakRcvdThpt, floatCompare = 1;
 
1162
          break;
 
1163
        default:
 
1164
          idx+=2;
 
1165
          if(idx < numIpProtosToMonitor) {
 
1166
            a_ = (*a)->protoIPTrafficInfos[idx].receivedLocally
 
1167
              +(*a)->protoIPTrafficInfos[idx].receivedFromRemote;
 
1168
            b_ = (*b)->protoIPTrafficInfos[idx].receivedLocally
 
1169
              +(*b)->protoIPTrafficInfos[idx].receivedFromRemote;
 
1170
          } else {
 
1171
            int i;
 
1172
 
 
1173
            a_ = 0, b_ = 0;
 
1174
 
 
1175
            for(i=0; i<numIpProtosToMonitor; i++) {
 
1176
              a_ += (*a)->protoIPTrafficInfos[i].receivedLocally
 
1177
                +(*a)->protoIPTrafficInfos[i].receivedFromRemote;
 
1178
              b_ += (*b)->protoIPTrafficInfos[i].receivedLocally
 
1179
                +(*b)->protoIPTrafficInfos[i].receivedFromRemote;
 
1180
            }
 
1181
 
 
1182
            if((*a)->bytesReceived > a_)
 
1183
              a_ = (*a)->bytesReceived-a_;
 
1184
            else
 
1185
              a_ = 0;
 
1186
 
 
1187
            if((*b)->bytesReceived > b_)
 
1188
              b_ = (*b)->bytesReceived-b_;
 
1189
            else
 
1190
              b_ = 0;
 
1191
          }
 
1192
        }
 
1193
      break;
 
1194
    }
 
1195
    break;
 
1196
  case 4:
 
1197
    if(sortSendMode)
 
1198
      switch(screenNumber) {
 
1199
      case 0:
 
1200
        a_ = (*a)->qnxSent, b_ = (*b)->qnxSent;
 
1201
        break;
 
1202
      default:
 
1203
        fa_ = (*a)->actualSentPktThpt, fb_ = (*b)->actualSentPktThpt, floatCompare = 1;
 
1204
        break;
 
1205
      }
 
1206
    else
 
1207
      switch(screenNumber) {
 
1208
      case 0:
 
1209
        a_ = (*a)->qnxReceived, b_ = (*b)->qnxReceived;
 
1210
        break;
 
1211
      case MAX_NUM_PROTOS_SCREENS:
 
1212
        fa_ = (*a)->actualRcvdPktThpt, fb_ = (*b)->actualRcvdPktThpt, floatCompare = 1;
 
1213
        break;
 
1214
      }
 
1215
    break;
 
1216
  case 5:
 
1217
    if(sortSendMode) {
 
1218
      switch(screenNumber) {
 
1219
      case 0:
 
1220
        a_ = (*a)->otherSent, b_ = (*b)->otherSent;
 
1221
        break;
 
1222
      case 1:
 
1223
        a_ = (*a)->stpSent, b_ = (*b)->stpSent;
 
1224
        break;
 
1225
      case MAX_NUM_PROTOS_SCREENS:
 
1226
        fa_ = (*a)->averageSentPktThpt, fb_ = (*b)->averageSentPktThpt, floatCompare = 1;
 
1227
        break;
 
1228
      }
 
1229
    } else {
 
1230
      switch(screenNumber) {
 
1231
      case 0:
 
1232
        a_ = (*a)->otherReceived, b_ = (*b)->otherReceived;
 
1233
        break;
 
1234
      case 1:
 
1235
        a_ = (*a)->stpReceived, b_ = (*b)->stpReceived;
 
1236
        break;
 
1237
      }
 
1238
    }
 
1239
 
 
1240
    break;
 
1241
  case 6:
 
1242
    if(sortSendMode)
 
1243
      fa_ = (*a)->peakSentPktThpt, fb_ = (*b)->peakSentPktThpt, floatCompare = 1;
 
1244
    else
 
1245
      fa_ = (*a)->peakRcvdPktThpt, fb_ = (*b)->peakRcvdPktThpt, floatCompare = 1;
 
1246
  }
 
1247
 
 
1248
  columnSort = oldColumnSort;
 
1249
 
 
1250
  if(floatCompare == 0) {
 
1251
    if(a_ < b_) {
 
1252
      return(1);
 
1253
    } else if (a_ > b_) {
 
1254
      return(-1);
 
1255
    } else {
 
1256
      return(0);
 
1257
    }
 
1258
  } else {
 
1259
    if(fa_ < fb_) {
 
1260
      return(1);
 
1261
    } else if (fa_ > fb_) {
 
1262
      return(-1);
 
1263
    } else {
 
1264
      return(0);
 
1265
    }
 
1266
  }
 
1267
}
 
1268
 
 
1269
/* ******************************* */
 
1270
 
 
1271
int cmpMulticastFctn(const void *_a, const void *_b) {
 
1272
  HostTraffic **a = (HostTraffic **)_a;
 
1273
  HostTraffic **b = (HostTraffic **)_b;
 
1274
  int rc;
 
1275
 
 
1276
  if((a == NULL) && (b != NULL)) {
 
1277
    traceEvent(TRACE_WARNING, "WARNING (1)\n");
 
1278
    return(1);
 
1279
  } else if((a != NULL) && (b == NULL)) {
 
1280
    traceEvent(TRACE_WARNING, "WARNING (2)\n");
 
1281
    return(-1);
 
1282
  } else if((a == NULL) && (b == NULL)) {
 
1283
    traceEvent(TRACE_WARNING, "WARNING (3)\n");
 
1284
    return(0);
 
1285
  }
 
1286
 
 
1287
  switch(columnSort) {
 
1288
  case 2:
 
1289
    if((*a)->pktMulticastSent < (*b)->pktMulticastSent)
 
1290
      return(1);
 
1291
    else if ((*a)->pktMulticastSent > (*b)->pktMulticastSent)
 
1292
      return(-1);
 
1293
    else
 
1294
      return(0);
 
1295
    break; /* NOTREACHED */
 
1296
  case 3:
 
1297
    if((*a)->bytesMulticastSent < (*b)->bytesMulticastSent)
 
1298
      return(1);
 
1299
    else if ((*a)->bytesMulticastSent > (*b)->bytesMulticastSent)
 
1300
      return(-1);
 
1301
    else
 
1302
      return(0);
 
1303
    break; /* NOTREACHED */
 
1304
  case 4:
 
1305
    if((*a)->pktMulticastRcvd < (*b)->pktMulticastRcvd)
 
1306
      return(1);
 
1307
    else if ((*a)->pktMulticastRcvd > (*b)->pktMulticastRcvd)
 
1308
      return(-1);
 
1309
    else
 
1310
      return(0);
 
1311
    break; /* NOTREACHED */
 
1312
  case 5:
 
1313
    if((*a)->bytesMulticastRcvd < (*b)->bytesMulticastRcvd)
 
1314
      return(1);
 
1315
    else if ((*a)->bytesMulticastRcvd > (*b)->bytesMulticastRcvd)
 
1316
      return(-1);
 
1317
    else
 
1318
      return(0);
 
1319
    break; /* NOTREACHED */
 
1320
 
 
1321
  default:
 
1322
#ifdef MULTITHREADED
 
1323
    accessMutex(&addressResolutionMutex, "cmpMulticastFctn");
 
1324
#endif
 
1325
 
 
1326
    rc = strcmp((*a)->hostSymIpAddress, /* Host name */
 
1327
                (*b)->hostSymIpAddress);
 
1328
#ifdef MULTITHREADED
 
1329
    releaseMutex(&addressResolutionMutex);
 
1330
#endif
 
1331
    return(rc);
 
1332
  }
 
1333
}
 
1334
 
 
1335
/* ******************************* */
 
1336
 
 
1337
void getProtocolDataSent(TrafficCounter *c,
 
1338
                         TrafficCounter *d,
 
1339
                         TrafficCounter *e,
 
1340
                         HostTraffic *el) {
 
1341
  int idx;
 
1342
 
 
1343
  switch(screenNumber) {
 
1344
  case 0:
 
1345
    (*c) = el->tcpSentLocally + el->tcpSentRemotely;
 
1346
    (*d) = el->udpSentLocally + el->udpSentRemotely;
 
1347
    (*e) = el->icmpSent;
 
1348
    break;
 
1349
  case 1:
 
1350
    (*c) = el->dlcSent;
 
1351
    (*d) = el->ipxSent;
 
1352
    (*e) = el->decnetSent;
 
1353
    break;
 
1354
  case 2:
 
1355
    (*c) = el->arp_rarpSent;
 
1356
    (*d) = el->appletalkSent;
 
1357
    (*e) = el->ospfSent;
 
1358
    break;
 
1359
  case 3:
 
1360
    (*c) = el->netbiosSent;
 
1361
    (*d) = el->igmpSent;
 
1362
    (*e) = el->osiSent;
 
1363
    break;
 
1364
  case 4:
 
1365
    (*c) = el->qnxSent;
 
1366
    (*d) = el->otherSent;
 
1367
    (*e) = 0;
 
1368
    break;
 
1369
  default:
 
1370
    idx = (screenNumber-MAX_NUM_PROTOS_SCREENS)*3;
 
1371
    if(idx < numIpProtosToMonitor)
 
1372
      (*c) = el->protoIPTrafficInfos[idx].sentLocally
 
1373
        + el->protoIPTrafficInfos[idx].sentRemotely;
 
1374
    else
 
1375
      (*c) = 0;
 
1376
 
 
1377
    ++idx;
 
1378
    if(idx < numIpProtosToMonitor)
 
1379
      (*d) = el->protoIPTrafficInfos[idx].sentLocally
 
1380
        + el->protoIPTrafficInfos[idx].sentRemotely;
 
1381
    else
 
1382
      (*d) = 0;
 
1383
 
 
1384
    ++idx;
 
1385
    if(idx < numIpProtosToMonitor)
 
1386
      (*e) = el->protoIPTrafficInfos[idx].sentLocally
 
1387
        + el->protoIPTrafficInfos[idx].sentRemotely;
 
1388
    else
 
1389
      (*e) = 0;
 
1390
  }
 
1391
}
 
1392
 
 
1393
/* ******************************* */
 
1394
 
 
1395
void getProtocolDataReceived(TrafficCounter *c,
 
1396
                             TrafficCounter *d,
 
1397
                             TrafficCounter *e,
 
1398
                             HostTraffic *el) {
 
1399
  int idx;
 
1400
 
 
1401
  switch(screenNumber) {
 
1402
  case 0:
 
1403
    (*c) = el->tcpReceivedLocally + el->tcpReceivedFromRemote;
 
1404
    (*d) = el->udpReceivedLocally + el->udpReceivedFromRemote;
 
1405
    (*e) = el->icmpReceived;
 
1406
    break;
 
1407
  case 1:
 
1408
    (*c) = el->dlcReceived;
 
1409
    (*d) = el->ipxReceived;
 
1410
    (*e) = el->decnetReceived;
 
1411
    break;
 
1412
  case 2:
 
1413
    (*c) = el->arp_rarpReceived;
 
1414
    (*d) = el->appletalkReceived;
 
1415
    (*e) = el->ospfReceived;
 
1416
    break;
 
1417
  case 3:
 
1418
    (*c) = el->netbiosReceived;
 
1419
    (*d) = el->igmpReceived;
 
1420
    (*e) = el->osiReceived;
 
1421
    break;
 
1422
  case 4:
 
1423
    (*c) = el->qnxReceived;
 
1424
    (*d) = el->otherReceived;
 
1425
    (*e) = 0;
 
1426
    break;
 
1427
  default:
 
1428
    idx = (screenNumber-MAX_NUM_PROTOS_SCREENS)*3;
 
1429
    if(idx < numIpProtosToMonitor)
 
1430
      (*c) = el->protoIPTrafficInfos[idx].receivedLocally
 
1431
        + el->protoIPTrafficInfos[idx].receivedFromRemote;
 
1432
    else
 
1433
      (*c) = 0;
 
1434
 
 
1435
    ++idx;
 
1436
    if(idx < numIpProtosToMonitor)
 
1437
      (*d) = el->protoIPTrafficInfos[idx].receivedLocally
 
1438
        + el->protoIPTrafficInfos[idx].receivedFromRemote;
 
1439
    else
 
1440
      (*d) = 0;
 
1441
 
 
1442
    ++idx;
 
1443
    if(idx < numIpProtosToMonitor)
 
1444
      (*e) = el->protoIPTrafficInfos[idx].receivedLocally
 
1445
        + el->protoIPTrafficInfos[idx].receivedFromRemote;
 
1446
    else
 
1447
      (*e) = 0;
 
1448
  }
 
1449
}
 
1450
 
 
1451
/* *********************************** */
 
1452
 
 
1453
static char* getBgPctgColor(float pctg) {
 
1454
  if(pctg == 0)
 
1455
    return("");
 
1456
  else if(pctg <= 25)           /* < 25%       */
 
1457
    return("BGCOLOR=#C6EEF7");  /* 25% <=> 75% */
 
1458
  else if(pctg <= 75)
 
1459
    return("BGCOLOR=#C6EFC8");  /* > 75%       */
 
1460
  else
 
1461
    return("BGCOLOR=#FF3118");
 
1462
}
 
1463
 
 
1464
/* ******************************* */
 
1465
 
 
1466
void printHostThtpShort(HostTraffic *el, short dataSent) {
 
1467
  int i;
 
1468
  TrafficCounter tc;
 
1469
  char buf[64];
 
1470
 
 
1471
  for(i=0, tc=0; i<24; i++) {
 
1472
    if(dataSent)
 
1473
      tc += el->last24HoursBytesSent[i];
 
1474
    else
 
1475
      tc += el->last24HoursBytesRcvd[i];
 
1476
  }
 
1477
 
 
1478
  for(i=0; i<24; i++) {
 
1479
    float pctg;
 
1480
 
 
1481
    if(tc > 0) {
 
1482
      if(dataSent)
 
1483
        pctg = (float)(el->last24HoursBytesSent[i]*100)/(float)tc;
 
1484
      else
 
1485
        pctg = (float)(el->last24HoursBytesRcvd[i]*100)/(float)tc;
 
1486
    } else
 
1487
      pctg = 0;
 
1488
 
 
1489
    if(snprintf(buf, sizeof(buf), "<TD ALIGN=RIGHT %s>&nbsp;</TD>",
 
1490
                getBgPctgColor(pctg)) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1491
    sendString(buf);
 
1492
  }
 
1493
}
 
1494
 
 
1495
/* ******************************* */
 
1496
 
 
1497
int cmpHostsFctn(const void *_a, const void *_b) {
 
1498
  struct hostTraffic **a = (struct hostTraffic **)_a;
 
1499
  struct hostTraffic **b = (struct hostTraffic **)_b;
 
1500
  char *name_a, *name_b;
 
1501
  TrafficCounter a_=0, b_=0;
 
1502
  int rc;
 
1503
 
 
1504
  switch(columnSort) {
 
1505
  case 2: /* IP Address */
 
1506
    if((*a)->hostIpAddress.s_addr > (*b)->hostIpAddress.s_addr)
 
1507
      return(1);
 
1508
    else if((*a)->hostIpAddress.s_addr < (*b)->hostIpAddress.s_addr)
 
1509
      return(-1);
 
1510
    else
 
1511
      return(0);
 
1512
    break;
 
1513
 
 
1514
  case 3: /* Data Sent */
 
1515
    switch(sortFilter) {
 
1516
    case REMOTE_TO_LOCAL_ACCOUNTING:
 
1517
      a_ = (*a)->bytesSentLocally;
 
1518
      b_ = (*b)->bytesSentLocally;
 
1519
      break;
 
1520
    case LOCAL_TO_REMOTE_ACCOUNTING:
 
1521
      a_ = (*a)->bytesSentRemotely;
 
1522
      b_ = (*b)->bytesSentRemotely;
 
1523
      break;
 
1524
    case LOCAL_TO_LOCAL_ACCOUNTING:
 
1525
      a_ = (*a)->bytesSentLocally;
 
1526
      b_ = (*b)->bytesSentLocally;
 
1527
      break;
 
1528
    }
 
1529
    if(a_ < b_) return(1); else if (a_ > b_) return(-1); else return(0);
 
1530
    break;
 
1531
 
 
1532
  case 4: /* Data Rcvd */
 
1533
    switch(sortFilter) {
 
1534
    case REMOTE_TO_LOCAL_ACCOUNTING:
 
1535
      a_ = (*a)->bytesReceivedLocally;
 
1536
      b_ = (*b)->bytesReceivedLocally;
 
1537
      break;
 
1538
    case LOCAL_TO_REMOTE_ACCOUNTING:
 
1539
      a_ = (*a)->bytesReceivedFromRemote;
 
1540
      b_ = (*b)->bytesReceivedFromRemote;
 
1541
      break;
 
1542
    case LOCAL_TO_LOCAL_ACCOUNTING:
 
1543
      a_ = (*a)->bytesReceivedLocally;
 
1544
      b_ = (*b)->bytesReceivedLocally;
 
1545
      break;
 
1546
    }
 
1547
    if(a_ < b_) return(1); else if (a_ > b_) return(-1); else return(0);
 
1548
    break;
 
1549
 
 
1550
  default: /* Host Name */
 
1551
#ifdef MULTITHREADED
 
1552
    accessMutex(&addressResolutionMutex, "cmpHostsFctn");
 
1553
#endif
 
1554
 
 
1555
    name_a = (*a)->hostSymIpAddress;
 
1556
 
 
1557
    if(name_a == NULL)
 
1558
      traceEvent(TRACE_WARNING, "Warning\n");
 
1559
    if((name_a == NULL) || (strcmp(name_a, "0.0.0.0") == 0)) {
 
1560
      name_a = (*a)->hostNumIpAddress;
 
1561
      if((name_a == NULL) || (name_a[0] == '\0'))
 
1562
        name_a = (*a)->ethAddressString;
 
1563
    }
 
1564
 
 
1565
    name_b = (*b)->hostSymIpAddress;
 
1566
 
 
1567
    if(name_b == NULL)
 
1568
      traceEvent(TRACE_WARNING, "Warning\n");
 
1569
    if((name_b == NULL) || (strcmp(name_b, "0.0.0.0") == 0)) {
 
1570
      name_b = (*b)->hostNumIpAddress;
 
1571
      if((name_b == NULL) || (name_b[0] == '\0'))
 
1572
        name_b = (*b)->ethAddressString;
 
1573
    }
 
1574
 
 
1575
#ifdef MULTITHREADED
 
1576
    releaseMutex(&addressResolutionMutex);
 
1577
#endif
 
1578
 
 
1579
    rc = strcasecmp(name_a, name_b); /* case insensitive */
 
1580
 
 
1581
    return(rc);
 
1582
  }
 
1583
}
 
1584
 
 
1585
/* ************************************ */
 
1586
 
 
1587
void printPacketStats(HostTraffic *el) {
 
1588
  char buf[BUF_SIZE];
 
1589
  int headerSent = 0;
 
1590
  char *tableHeader = "<center><TABLE BORDER=0><TR><TD>";
 
1591
 
 
1592
  /* *********************** */
 
1593
 
 
1594
  if(el->securityHostPkts != NULL) {
 
1595
    if(((el->securityHostPkts->rejectedTCPConnSent.value+
 
1596
         el->securityHostPkts->rejectedTCPConnRcvd.value+
 
1597
         el->securityHostPkts->establishedTCPConnSent.value+
 
1598
         el->securityHostPkts->establishedTCPConnRcvd.value+
 
1599
         el->securityHostPkts->synPktsSent.value+
 
1600
         el->securityHostPkts->synPktsRcvd.value) > 0)) {
 
1601
 
 
1602
      if(!headerSent) { printSectionTitle("Packet Statistics"); sendString(tableHeader); headerSent = 1; }
 
1603
 
 
1604
      sendString("<CENTER>\n"
 
1605
                 ""TABLE_ON"<TABLE BORDER=1 WIDTH=100%><TR><TH "TH_BG">TCP Connections</TH>"
 
1606
                 "<TH "TH_BG" COLSPAN=2>Directed to</TH>"
 
1607
                 "<TH "TH_BG" COLSPAN=2>Received From</TH></TR>\n");
 
1608
 
 
1609
      if((el->securityHostPkts->synPktsSent.value+el->securityHostPkts->synPktsRcvd.value) > 0) {
 
1610
        sendString("<TR><TH "TH_BG" ALIGN=LEFT>Attempted</TH>");
 
1611
        formatUsageCounter(el->securityHostPkts->synPktsSent, 0);
 
1612
        formatUsageCounter(el->securityHostPkts->synPktsRcvd, 0);
 
1613
        sendString("</TR>\n");
 
1614
      }
 
1615
 
 
1616
      if((el->securityHostPkts->establishedTCPConnSent.value+el->securityHostPkts->establishedTCPConnRcvd.value) > 0) {
 
1617
        sendString("<TR><TH "TH_BG" ALIGN=LEFT>Established</TH>");
 
1618
        formatUsageCounter(el->securityHostPkts->establishedTCPConnSent, el->securityHostPkts->synPktsSent.value);
 
1619
        formatUsageCounter(el->securityHostPkts->establishedTCPConnRcvd, el->securityHostPkts->synPktsRcvd.value);
 
1620
        sendString("</TR>\n");
 
1621
      }
 
1622
 
 
1623
      if((el->securityHostPkts->rejectedTCPConnSent.value+el->securityHostPkts->rejectedTCPConnRcvd.value) > 0) {
 
1624
        sendString("<TR><TH "TH_BG" ALIGN=LEFT>Rejected</TH>");
 
1625
        formatUsageCounter(el->securityHostPkts->rejectedTCPConnSent, el->securityHostPkts->synPktsSent.value);
 
1626
        formatUsageCounter(el->securityHostPkts->rejectedTCPConnRcvd, el->securityHostPkts->synPktsRcvd.value);
 
1627
        sendString("</TR>\n");
 
1628
      }
 
1629
 
 
1630
      sendString("</TABLE>"TABLE_OFF"<P>\n");
 
1631
      sendString("</CENTER>\n");
 
1632
    }
 
1633
 
 
1634
    /* *********************** */
 
1635
 
 
1636
    if((el->securityHostPkts->synPktsSent.value+el->securityHostPkts->synPktsRcvd.value
 
1637
        +el->securityHostPkts->rstAckPktsSent.value+el->securityHostPkts->rstAckPktsRcvd.value
 
1638
        +el->securityHostPkts->rstPktsSent.value+el->securityHostPkts->rstPktsRcvd.value
 
1639
        +el->securityHostPkts->synFinPktsSent.value+el->securityHostPkts->synFinPktsRcvd.value
 
1640
        +el->securityHostPkts->finPushUrgPktsSent.value+el->securityHostPkts->finPushUrgPktsRcvd.value
 
1641
        +el->securityHostPkts->nullPktsSent.value+el->securityHostPkts->nullPktsRcvd.value) > 0) {
 
1642
 
 
1643
      if(!headerSent) { printSectionTitle("Packet Statistics"); sendString(tableHeader); headerSent = 1; }
 
1644
 
 
1645
      sendString("<CENTER>\n"
 
1646
                 ""TABLE_ON"<TABLE BORDER=1 WIDTH=100%><TR><TH "TH_BG">TCP Flags</TH>"
 
1647
                 "<TH "TH_BG" COLSPAN=2>Pkts&nbsp;Sent</TH>"
 
1648
                 "<TH "TH_BG" COLSPAN=2>Pkts&nbsp;Received</TH></TR>\n");
 
1649
 
 
1650
      if((el->securityHostPkts->synPktsSent.value+el->securityHostPkts->synPktsRcvd.value) > 0) {
 
1651
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>SYN</TH>",
 
1652
                    getRowColor()) < 0)
 
1653
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1654
        sendString(buf);
 
1655
        formatUsageCounter(el->securityHostPkts->synPktsSent, 0);
 
1656
        formatUsageCounter(el->securityHostPkts->synPktsRcvd, 0);
 
1657
        sendString("</TR>\n");
 
1658
      }
 
1659
 
 
1660
      if((el->securityHostPkts->rstAckPktsSent.value+el->securityHostPkts->rstAckPktsRcvd.value) > 0) {
 
1661
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>RST|ACK</TH>",
 
1662
                    getRowColor()) < 0)
 
1663
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1664
        sendString(buf);
 
1665
        formatUsageCounter(el->securityHostPkts->rstAckPktsSent, 0);
 
1666
        formatUsageCounter(el->securityHostPkts->rstAckPktsRcvd, 0);
 
1667
        sendString("</TR>\n");
 
1668
      }
 
1669
 
 
1670
      if((el->securityHostPkts->rstPktsSent.value+el->securityHostPkts->rstPktsRcvd.value) > 0) {
 
1671
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>RST</TH>",
 
1672
                    getRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1673
        sendString(buf);
 
1674
        formatUsageCounter(el->securityHostPkts->rstPktsSent, 0);
 
1675
        formatUsageCounter(el->securityHostPkts->rstPktsRcvd, 0);
 
1676
        sendString("</TR>\n");
 
1677
      }
 
1678
 
 
1679
      if((el->securityHostPkts->synFinPktsSent.value+el->securityHostPkts->synFinPktsRcvd.value) > 0) {
 
1680
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>SYN|FIN</TH>",
 
1681
                    getRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1682
        sendString(buf);
 
1683
        formatUsageCounter(el->securityHostPkts->synFinPktsSent, 0);
 
1684
        formatUsageCounter(el->securityHostPkts->synFinPktsRcvd, 0);
 
1685
        sendString("</TR>\n");
 
1686
      }
 
1687
 
 
1688
      if((el->securityHostPkts->finPushUrgPktsSent.value+el->securityHostPkts->finPushUrgPktsRcvd.value) > 0) {
 
1689
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>FIN|PUSH|URG</TH>",
 
1690
                    getRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1691
        sendString(buf);
 
1692
        formatUsageCounter(el->securityHostPkts->finPushUrgPktsSent, 0);
 
1693
        formatUsageCounter(el->securityHostPkts->finPushUrgPktsRcvd, 0);
 
1694
        sendString("</TR>\n");
 
1695
      }
 
1696
 
 
1697
      if((el->securityHostPkts->nullPktsSent.value+el->securityHostPkts->nullPktsRcvd.value) > 0) {
 
1698
        sendString("<TR><TH "TH_BG" ALIGN=LEFT>NULL</TH>");
 
1699
        formatUsageCounter(el->securityHostPkts->nullPktsSent, 0);
 
1700
        formatUsageCounter(el->securityHostPkts->nullPktsRcvd, 0);
 
1701
        sendString("</TR>\n");
 
1702
      }
 
1703
 
 
1704
      sendString("</TABLE>"TABLE_OFF"<P>\n");
 
1705
      sendString("</CENTER>\n");
 
1706
    }
 
1707
 
 
1708
    /* *********************** */
 
1709
 
 
1710
    if(((el->securityHostPkts->ackScanSent.value+el->securityHostPkts->ackScanRcvd.value
 
1711
         +el->securityHostPkts->xmasScanSent.value+el->securityHostPkts->xmasScanRcvd.value
 
1712
         +el->securityHostPkts->finScanSent.value+el->securityHostPkts->finScanRcvd.value
 
1713
         +el->securityHostPkts->synFinPktsSent.value+el->securityHostPkts->synFinPktsRcvd.value
 
1714
         +el->securityHostPkts->nullScanSent.value+el->securityHostPkts->nullScanRcvd.value
 
1715
         +el->securityHostPkts->udpToClosedPortSent.value
 
1716
         +el->securityHostPkts->udpToClosedPortRcvd.value
 
1717
         +el->securityHostPkts->udpToDiagnosticPortSent.value
 
1718
         +el->securityHostPkts->udpToDiagnosticPortRcvd.value
 
1719
         +el->securityHostPkts->tcpToDiagnosticPortSent.value
 
1720
         +el->securityHostPkts->tcpToDiagnosticPortRcvd.value
 
1721
         +el->securityHostPkts->tinyFragmentSent.value
 
1722
         +el->securityHostPkts->tinyFragmentRcvd.value
 
1723
         +el->securityHostPkts->icmpFragmentSent.value
 
1724
         +el->securityHostPkts->icmpFragmentRcvd.value
 
1725
         +el->securityHostPkts->overlappingFragmentSent.value
 
1726
         +el->securityHostPkts->overlappingFragmentRcvd.value
 
1727
         +el->securityHostPkts->closedEmptyTCPConnSent.value
 
1728
         +el->securityHostPkts->closedEmptyTCPConnRcvd.value
 
1729
         +el->securityHostPkts->malformedPktsSent.value
 
1730
         +el->securityHostPkts->malformedPktsRcvd.value
 
1731
         ) > 0)) {
 
1732
 
 
1733
      if(!headerSent) { printSectionTitle("Packet Statistics"); sendString(tableHeader); headerSent = 1; }
 
1734
 
 
1735
      sendString("<CENTER>\n"
 
1736
                 ""TABLE_ON"<TABLE BORDER=1 WIDTH=100%><TR><TH "TH_BG">Anomaly</TH>"
 
1737
                 "<TH "TH_BG" COLSPAN=2>Pkts&nbsp;Sent&nbsp;to</TH>"
 
1738
                 "<TH "TH_BG" COLSPAN=2>Pkts&nbsp;Received&nbsp;from</TH>"
 
1739
                 "</TR>\n");
 
1740
 
 
1741
      if((el->securityHostPkts->ackScanSent.value+el->securityHostPkts->ackScanRcvd.value) > 0) {
 
1742
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>ACK Scan</TH>",
 
1743
                    getRowColor()) < 0)
 
1744
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1745
        sendString(buf);
 
1746
        formatUsageCounter(el->securityHostPkts->ackScanSent, 0);
 
1747
        formatUsageCounter(el->securityHostPkts->ackScanRcvd, 0);
 
1748
        sendString("</TR>\n");
 
1749
      }
 
1750
 
 
1751
      if((el->securityHostPkts->xmasScanSent.value+el->securityHostPkts->xmasScanRcvd.value) > 0) {
 
1752
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>XMAS Scan</TH>",
 
1753
                    getRowColor()) < 0)
 
1754
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1755
        sendString(buf);
 
1756
        formatUsageCounter(el->securityHostPkts->xmasScanSent, 0);
 
1757
        formatUsageCounter(el->securityHostPkts->xmasScanRcvd, 0);
 
1758
        sendString("</TR>\n");
 
1759
      }
 
1760
 
 
1761
      if((el->securityHostPkts->finScanSent.value+el->securityHostPkts->finScanRcvd.value) > 0) {
 
1762
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>FIN Scan</TH>",
 
1763
                    getRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1764
        sendString(buf);
 
1765
        formatUsageCounter(el->securityHostPkts->finScanSent, 0);
 
1766
        formatUsageCounter(el->securityHostPkts->finScanRcvd, 0);
 
1767
        sendString("</TR>\n");
 
1768
      }
 
1769
 
 
1770
      if((el->securityHostPkts->nullScanSent.value+el->securityHostPkts->nullScanRcvd.value) > 0) {
 
1771
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>NULL Scan</TH>",
 
1772
                    getRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1773
        sendString(buf);
 
1774
        formatUsageCounter(el->securityHostPkts->nullScanSent, 0);
 
1775
        formatUsageCounter(el->securityHostPkts->nullScanRcvd, 0);
 
1776
        sendString("</TR>\n");
 
1777
      }
 
1778
 
 
1779
      if((el->securityHostPkts->udpToClosedPortSent.value+
 
1780
          el->securityHostPkts->udpToClosedPortRcvd.value) > 0) {
 
1781
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>UDP Pkt to Closed Port</TH>",
 
1782
                    getRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1783
        sendString(buf);
 
1784
        formatUsageCounter(el->securityHostPkts->udpToClosedPortSent, 0);
 
1785
        formatUsageCounter(el->securityHostPkts->udpToClosedPortRcvd, 0);
 
1786
        sendString("</TR>\n");
 
1787
      }
 
1788
 
 
1789
      if((el->securityHostPkts->udpToDiagnosticPortSent.value+
 
1790
          el->securityHostPkts->udpToDiagnosticPortRcvd.value) > 0) {
 
1791
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>UDP Pkt Disgnostic Port</TH>",
 
1792
                    getRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1793
        sendString(buf);
 
1794
        formatUsageCounter(el->securityHostPkts->udpToDiagnosticPortSent, 0);
 
1795
        formatUsageCounter(el->securityHostPkts->udpToDiagnosticPortRcvd, 0);
 
1796
        sendString("</TR>\n");
 
1797
      }
 
1798
 
 
1799
      if((el->securityHostPkts->tcpToDiagnosticPortSent.value+
 
1800
          el->securityHostPkts->tcpToDiagnosticPortRcvd.value) > 0) {
 
1801
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>TCP Pkt Disgnostic Port</TH>",
 
1802
                    getRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1803
        sendString(buf);
 
1804
        formatUsageCounter(el->securityHostPkts->tcpToDiagnosticPortSent, 0);
 
1805
        formatUsageCounter(el->securityHostPkts->tcpToDiagnosticPortRcvd, 0);
 
1806
        sendString("</TR>\n");
 
1807
      }
 
1808
 
 
1809
      if((el->securityHostPkts->tinyFragmentSent.value+
 
1810
          el->securityHostPkts->tinyFragmentRcvd.value) > 0) {
 
1811
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>Tiny Fragments</TH>",
 
1812
                    getRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1813
        sendString(buf);
 
1814
        formatUsageCounter(el->securityHostPkts->tinyFragmentSent, 0);
 
1815
        formatUsageCounter(el->securityHostPkts->tinyFragmentRcvd, 0);
 
1816
        sendString("</TR>\n");
 
1817
      }
 
1818
 
 
1819
      if((el->securityHostPkts->icmpFragmentSent.value+
 
1820
          el->securityHostPkts->icmpFragmentRcvd.value) > 0) {
 
1821
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>ICMP Fragments</TH>",
 
1822
                    getRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1823
        sendString(buf);
 
1824
        formatUsageCounter(el->securityHostPkts->icmpFragmentSent, 0);
 
1825
        formatUsageCounter(el->securityHostPkts->icmpFragmentRcvd, 0);
 
1826
        sendString("</TR>\n");
 
1827
      }
 
1828
 
 
1829
      if((el->securityHostPkts->overlappingFragmentSent.value+
 
1830
          el->securityHostPkts->overlappingFragmentRcvd.value) > 0) {
 
1831
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>Overlapping Fragments</TH>",
 
1832
                    getRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1833
        sendString(buf);
 
1834
        formatUsageCounter(el->securityHostPkts->overlappingFragmentSent, 0);
 
1835
        formatUsageCounter(el->securityHostPkts->overlappingFragmentRcvd, 0);
 
1836
        sendString("</TR>\n");
 
1837
      }
 
1838
 
 
1839
      if((el->securityHostPkts->closedEmptyTCPConnSent.value+
 
1840
          el->securityHostPkts->closedEmptyTCPConnRcvd.value) > 0) {
 
1841
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>Closed Empty TCP Conn.</TH>",
 
1842
                    getRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1843
        sendString(buf);
 
1844
        formatUsageCounter(el->securityHostPkts->closedEmptyTCPConnSent, 0);
 
1845
        formatUsageCounter(el->securityHostPkts->closedEmptyTCPConnRcvd, 0);
 
1846
        sendString("</TR>\n");
 
1847
      }
 
1848
 
 
1849
      if((el->securityHostPkts->malformedPktsSent.value+
 
1850
          el->securityHostPkts->malformedPktsRcvd.value) > 0) {
 
1851
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>Malformed Pkts</TH>",
 
1852
                    getRowColor()) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1853
        sendString(buf);
 
1854
        formatUsageCounter(el->securityHostPkts->malformedPktsSent, 0);
 
1855
        formatUsageCounter(el->securityHostPkts->malformedPktsRcvd, 0);
 
1856
        sendString("</TR>\n");
 
1857
      }
 
1858
 
 
1859
      sendString("</TABLE>"TABLE_OFF"<P>\n");
 
1860
      sendString("</CENTER>\n");
 
1861
    }
 
1862
  }
 
1863
 
 
1864
  if(el->arpReqPktsSent+el->arpReplyPktsSent+el->arpReplyPktsRcvd > 0) {
 
1865
    if(!headerSent) {
 
1866
      printSectionTitle("Packet Statistics");
 
1867
      sendString(tableHeader);
 
1868
      headerSent = 1;
 
1869
    }
 
1870
 
 
1871
    sendString("<CENTER>\n"
 
1872
               ""TABLE_ON"<TABLE BORDER=1 WIDTH=100%><TR>"
 
1873
               "<TH "TH_BG">ARP</TH>"
 
1874
               "<TH "TH_BG">Packet</TH>"
 
1875
               "</TR>\n");
 
1876
 
 
1877
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>Request Sent</TH>"
 
1878
                "<TD "TH_BG" ALIGN=RIGHT>%s</TD></TR>",
 
1879
                getRowColor(),
 
1880
                formatPkts(el->arpReqPktsSent)) < 0)
 
1881
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1882
    sendString(buf);
 
1883
 
 
1884
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>Reply Rcvd</TH>"
 
1885
                "<TD "TH_BG" ALIGN=RIGHT>%s (%.1f %%)</TD></TR>",
 
1886
                getRowColor(),
 
1887
                formatPkts(el->arpReplyPktsRcvd),
 
1888
                ((el->arpReqPktsSent > 0) ?
 
1889
                (float)((el->arpReplyPktsRcvd*100)/(float)el->arpReqPktsSent) : 0)) < 0)
 
1890
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1891
    sendString(buf);
 
1892
 
 
1893
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>Reply Sent</TH>"
 
1894
                "<TD "TH_BG" ALIGN=RIGHT>%s</TD></TR>",
 
1895
                getRowColor(),
 
1896
                formatPkts(el->arpReplyPktsSent)) < 0)
 
1897
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1898
    sendString(buf);
 
1899
 
 
1900
    sendString("</TABLE>"TABLE_OFF"<P>\n");
 
1901
    sendString("</CENTER>\n");
 
1902
  }
 
1903
 
 
1904
  if(headerSent) { sendString("</TD></TR></TABLE></center>"); }
 
1905
}
 
1906
 
 
1907
/* ************************************ */
 
1908
 
 
1909
void printHostFragmentStats(HostTraffic *el) {
 
1910
  TrafficCounter totalSent, totalReceived;
 
1911
  char buf[BUF_SIZE];
 
1912
 
 
1913
  totalSent = el->tcpFragmentsSent + el->udpFragmentsSent + el->icmpFragmentsSent;
 
1914
  totalReceived = el->tcpFragmentsReceived + el->udpFragmentsReceived + el->icmpFragmentsReceived;
 
1915
  
 
1916
 if((totalSent == 0) && (totalReceived == 0))
 
1917
    return;
 
1918
 
 
1919
  printSectionTitle("IP Fragments Distribution");
 
1920
 
 
1921
  sendString("<CENTER>\n"
 
1922
             ""TABLE_ON"<TABLE BORDER=1><TR><TH "TH_BG" WIDTH=100>Protocol</TH>"
 
1923
             "<TH "TH_BG" WIDTH=200 COLSPAN=2>Data&nbsp;Sent</TH>"
 
1924
             "<TH "TH_BG" WIDTH=200 COLSPAN=2>Data&nbsp;Received</TH></TR>\n");
 
1925
 
 
1926
  printTableDoubleEntry(buf, sizeof(buf), "TCP", COLOR_1, (float)el->tcpFragmentsSent/1024,
 
1927
                        100*((float)SD(el->tcpFragmentsSent, totalSent)),
 
1928
                        (float)el->tcpFragmentsReceived/1024,
 
1929
                        100*((float)SD(el->tcpFragmentsReceived, totalReceived)));
 
1930
 
 
1931
  printTableDoubleEntry(buf, sizeof(buf), "UDP", COLOR_1, (float)el->udpFragmentsSent/1024,
 
1932
                        100*((float)SD(el->udpFragmentsSent, totalSent)),
 
1933
                        (float)el->udpFragmentsReceived/1024,
 
1934
                        100*((float)SD(el->udpFragmentsReceived, totalReceived)));
 
1935
 
 
1936
  printTableDoubleEntry(buf, sizeof(buf), "ICMP", COLOR_1, (float)el->icmpFragmentsSent/1024,
 
1937
                        100*((float)SD(el->icmpFragmentsSent, totalSent)),
 
1938
                        (float)el->icmpFragmentsReceived/1024,
 
1939
                        100*((float)SD(el->icmpFragmentsReceived, totalReceived)));
 
1940
 
 
1941
#ifdef HAVE_GDCHART
 
1942
  {
 
1943
    if((totalSent > 0) || (totalReceived > 0)) {
 
1944
      if(snprintf(buf, sizeof(buf), 
 
1945
                  "<TR %s><TH "TH_BG" ALIGN=LEFT>Fragment Distribution</TH>",
 
1946
                  getRowColor()) < 0)
 
1947
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1948
      sendString(buf);
 
1949
      
 
1950
      if(totalSent > 0) {
 
1951
        if(snprintf(buf, sizeof(buf),
 
1952
                    "<TD "TH_BG" ALIGN=RIGHT COLSPAN=2><IMG SRC=hostFragmentDistrib-%s"CHART_FORMAT"?1></TD>",
 
1953
                    el->hostNumIpAddress[0] == '\0' ?  el->ethAddressString : el->hostNumIpAddress) < 0)
 
1954
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1955
        sendString(buf);
 
1956
      } else {
 
1957
        sendString("<TD "TH_BG" ALIGN=RIGHT COLSPAN=2>&nbsp;</TD>");
 
1958
      }
 
1959
 
 
1960
      if(totalReceived > 0) {
 
1961
        if(snprintf(buf, sizeof(buf),
 
1962
                    "<TD "TH_BG" ALIGN=RIGHT COLSPAN=2><IMG SRC=hostFragmentDistrib-%s"CHART_FORMAT"></TD>",
 
1963
                    el->hostNumIpAddress[0] == '\0' ?  el->ethAddressString : el->hostNumIpAddress) < 0)
 
1964
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1965
        sendString(buf);
 
1966
      } else {
 
1967
        sendString("<TD "TH_BG" ALIGN=RIGHT COLSPAN=2>&nbsp;</TD>");
 
1968
      }
 
1969
 
 
1970
      sendString("</TD></TR>");
 
1971
 
 
1972
      /* ***************************************** */
 
1973
 
 
1974
      if(snprintf(buf, sizeof(buf), 
 
1975
                  "<TR %s><TH "TH_BG" ALIGN=LEFT>IP Fragment Distribution</TH>",
 
1976
                  getRowColor()) < 0)
 
1977
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1978
      sendString(buf);
 
1979
      
 
1980
      if(totalSent > 0) {
 
1981
        if(snprintf(buf, sizeof(buf),
 
1982
                    "<TD "TH_BG" ALIGN=RIGHT COLSPAN=2><IMG SRC=hostTotalFragmentDistrib-%s"CHART_FORMAT"?1></TD>",
 
1983
                    el->hostNumIpAddress[0] == '\0' ?  el->ethAddressString : el->hostNumIpAddress) < 0)
 
1984
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1985
        sendString(buf);
 
1986
      } else {
 
1987
        sendString("<TD "TH_BG" ALIGN=RIGHT COLSPAN=2>&nbsp;</TD>");
 
1988
      }
 
1989
 
 
1990
      if(totalReceived > 0) {
 
1991
        if(snprintf(buf, sizeof(buf),
 
1992
                    "<TD "TH_BG" ALIGN=RIGHT COLSPAN=2><IMG SRC=hostTotalFragmentDistrib-%s"CHART_FORMAT"></TD>",
 
1993
                    el->hostNumIpAddress[0] == '\0' ?  el->ethAddressString : el->hostNumIpAddress) < 0)
 
1994
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
1995
        sendString(buf);
 
1996
      } else {
 
1997
        sendString("<TD "TH_BG" ALIGN=RIGHT COLSPAN=2>&nbsp;</TD>");
 
1998
      }
 
1999
 
 
2000
      sendString("</TD></TR>");
 
2001
    }
 
2002
  }
 
2003
#endif
 
2004
 
 
2005
  sendString("</TABLE>"TABLE_OFF"<P>\n");
 
2006
  sendString("</CENTER>\n");  
 
2007
}
 
2008
 
 
2009
/* ************************************ */
 
2010
 
 
2011
void printHostTrafficStats(HostTraffic *el) {
 
2012
  int i, a, b;
 
2013
  TrafficCounter totalSent, totalReceived;
 
2014
  TrafficCounter actTotalSent, actTotalReceived;
 
2015
  char buf[BUF_SIZE];
 
2016
 
 
2017
  totalSent = el->tcpSentLocally+el->tcpSentRemotely+el->udpSentLocally+el->udpSentRemotely;
 
2018
  totalSent += el->icmpSent+el->ospfSent+el->igmpSent+el->ipxSent+el->dlcSent+el->arp_rarpSent;
 
2019
  totalSent +=  el->decnetSent+el->appletalkSent+el->netbiosSent+
 
2020
    el->osiSent+el->qnxSent+el->stpSent+el->otherSent;
 
2021
 
 
2022
  totalReceived = el->tcpReceivedLocally+el->tcpReceivedFromRemote;
 
2023
  totalReceived += el->udpReceivedLocally+el->udpReceivedFromRemote;
 
2024
  totalReceived += el->icmpReceived+el->ospfReceived+el->igmpReceived;
 
2025
  totalReceived += el->ipxReceived+el->dlcReceived+el->arp_rarpReceived;
 
2026
  totalReceived += el->decnetReceived+el->appletalkReceived;
 
2027
  totalReceived += el->osiReceived+el->netbiosReceived+el->qnxReceived
 
2028
    +el->stpReceived+el->otherReceived;
 
2029
 
 
2030
  actTotalSent = el->tcpSentLocally+el->tcpSentRemotely;
 
2031
  actTotalReceived = el->tcpReceivedLocally+el->tcpReceivedFromRemote;
 
2032
 
 
2033
  printHostEvents(el, -1, -1);
 
2034
  printHostHourlyTraffic(el);
 
2035
  printPacketStats(el);
 
2036
 
 
2037
  if((totalSent == 0) && (totalReceived == 0))
 
2038
    return;
 
2039
 
 
2040
  printSectionTitle("Protocol Distribution");
 
2041
 
 
2042
  sendString("<CENTER>\n"
 
2043
             ""TABLE_ON"<TABLE BORDER=1><TR><TH "TH_BG" WIDTH=100>Protocol</TH>"
 
2044
             "<TH "TH_BG" WIDTH=200 COLSPAN=2>Data&nbsp;Sent</TH>"
 
2045
             "<TH "TH_BG" WIDTH=200 COLSPAN=2>Data&nbsp;Received</TH></TR>\n");
 
2046
 
 
2047
  printTableDoubleEntry(buf, sizeof(buf), "TCP", COLOR_1, (float)actTotalSent/1024,
 
2048
                        100*((float)SD(actTotalSent, totalSent)),
 
2049
                        (float)actTotalReceived/1024,
 
2050
                        100*((float)SD(actTotalReceived, totalReceived)));
 
2051
 
 
2052
  actTotalSent = el->udpSentLocally+el->udpSentRemotely;
 
2053
  actTotalReceived = el->udpReceivedLocally+el->udpReceivedFromRemote;
 
2054
 
 
2055
/*#if 0 */
 
2056
  printTableDoubleEntry(buf, sizeof(buf), "UDP", COLOR_1, (float)actTotalSent/1024,
 
2057
                        100*((float)SD(actTotalSent, totalSent)),
 
2058
                        (float)actTotalReceived/1024,
 
2059
                        100*((float)SD(actTotalReceived, totalReceived)));
 
2060
 
 
2061
  printTableDoubleEntry(buf, sizeof(buf), "ICMP", COLOR_1, (float)el->icmpSent/1024,
 
2062
                        100*((float)SD(el->icmpSent, totalSent)),
 
2063
                        (float)el->icmpReceived/1024,
 
2064
                        100*((float)SD(el->icmpReceived, totalReceived)));
 
2065
 
 
2066
  printTableDoubleEntry(buf, sizeof(buf), "(R)ARP", COLOR_1, (float)el->arp_rarpSent/1024,
 
2067
                        100*((float)SD(el->arp_rarpSent, totalSent)),
 
2068
                        (float)el->arp_rarpReceived/1024,
 
2069
                        100*((float)SD(el->arp_rarpReceived, totalReceived)));
 
2070
 
 
2071
  printTableDoubleEntry(buf, sizeof(buf), "DLC", COLOR_1, (float)el->dlcSent/1024,
 
2072
                        100*((float)SD(el->dlcSent, totalSent)),
 
2073
                        (float)el->dlcReceived/1024,
 
2074
                        100*((float)SD(el->dlcReceived, totalReceived)));
 
2075
 
 
2076
  printTableDoubleEntry(buf, sizeof(buf), "IPX", COLOR_1, (float)el->ipxSent/1024,
 
2077
                        100*((float)SD(el->ipxSent, totalSent)),
 
2078
                        (float)el->ipxReceived/1024,
 
2079
                        100*((float)SD(el->ipxReceived, totalReceived)));
 
2080
 
 
2081
  printTableDoubleEntry(buf, sizeof(buf), "Decnet", COLOR_1, (float)el->decnetSent/1024,
 
2082
                        100*((float)SD(el->decnetSent, totalSent)),
 
2083
                        (float)el->decnetReceived/1024,
 
2084
                        100*((float)SD(el->decnetReceived, totalReceived)));
 
2085
 
 
2086
  printTableDoubleEntry(buf, sizeof(buf), "AppleTalk", COLOR_1, (float)el->appletalkSent/1024,
 
2087
                        100*((float)SD(el->appletalkSent, totalSent)),
 
2088
                        (float)el->appletalkReceived/1024,
 
2089
                        100*((float)SD(el->appletalkReceived, totalReceived)));
 
2090
 
 
2091
  printTableDoubleEntry(buf, sizeof(buf), "OSPF", COLOR_1, (float)el->ospfSent/1024,
 
2092
                        100*((float)SD(el->ospfSent, totalSent)),
 
2093
                        (float)el->ospfReceived/1024,
 
2094
                        100*((float)SD(el->ospfReceived, totalReceived)));
 
2095
 
 
2096
  printTableDoubleEntry(buf, sizeof(buf), "NetBios", COLOR_1, (float)el->netbiosSent/1024,
 
2097
                        100*((float)SD(el->netbiosSent, totalSent)),
 
2098
                        (float)el->netbiosReceived/1024,
 
2099
                        100*((float)SD(el->netbiosReceived, totalReceived)));
 
2100
 
 
2101
  printTableDoubleEntry(buf, sizeof(buf), "IGMP", COLOR_1, (float)el->igmpSent/1024,
 
2102
                        100*((float)SD(el->igmpSent, totalSent)),
 
2103
                        (float)el->igmpReceived/1024,
 
2104
                        100*((float)SD(el->igmpReceived, totalReceived)));
 
2105
 
 
2106
  printTableDoubleEntry(buf, sizeof(buf), "OSI", COLOR_1, (float)el->osiSent/1024,
 
2107
                        100*((float)SD(el->osiSent, totalSent)),
 
2108
                        (float)el->osiReceived/1024,
 
2109
                        100*((float)SD(el->osiReceived, totalReceived)));
 
2110
 
 
2111
  printTableDoubleEntry(buf, sizeof(buf), "QNX", COLOR_1, (float)el->qnxSent/1024,
 
2112
                        100*((float)SD(el->qnxSent, totalSent)),
 
2113
                        (float)el->qnxReceived/1024,
 
2114
                        100*((float)SD(el->qnxReceived, totalReceived)));
 
2115
 
 
2116
  printTableDoubleEntry(buf, sizeof(buf), "STP", COLOR_1, (float)el->stpSent/1024,
 
2117
                        100*((float)SD(el->stpSent, totalSent)),
 
2118
                        (float)el->stpReceived/1024,
 
2119
                        100*((float)SD(el->stpReceived, totalReceived)));
 
2120
 
 
2121
  printTableDoubleEntry(buf, sizeof(buf), "Other", COLOR_1, (float)el->otherSent/1024,
 
2122
                        100*((float)SD(el->otherSent, totalSent)),
 
2123
                        (float)el->otherReceived/1024,
 
2124
                        100*((float)SD(el->otherReceived, totalReceived)));
 
2125
/*#endif */
 
2126
 
 
2127
#ifdef HAVE_GDCHART
 
2128
  {
 
2129
    totalSent = el->tcpSentLocally+el->tcpSentRemotely+
 
2130
      el->udpSentLocally+el->udpSentRemotely+
 
2131
      el->icmpSent+el->ospfSent+el->igmpSent+el->stpSent+
 
2132
      el->ipxSent+el->osiSent+el->dlcSent+
 
2133
      el->arp_rarpSent+el->decnetSent+el->appletalkSent+
 
2134
      el->netbiosSent+el->qnxSent+el->otherSent;
 
2135
 
 
2136
    totalReceived = el->tcpReceivedLocally+el->tcpReceivedFromRemote+
 
2137
      el->udpReceivedLocally+el->udpReceivedFromRemote+
 
2138
      el->icmpReceived+el->ospfReceived+el->igmpReceived+el->stpReceived+
 
2139
      el->ipxReceived+el->osiReceived+el->dlcReceived+
 
2140
      el->arp_rarpReceived+el->decnetReceived+el->appletalkReceived+
 
2141
      el->netbiosReceived+el->qnxReceived+el->otherReceived;
 
2142
 
 
2143
    if((totalSent > 0) || (totalReceived > 0)) {
 
2144
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>Protocol Distribution</TH>",
 
2145
                  getRowColor()) < 0)
 
2146
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2147
      sendString(buf);
 
2148
 
 
2149
      if(totalSent > 0) {
 
2150
        if(snprintf(buf, sizeof(buf),
 
2151
                    "<TD "TH_BG" ALIGN=RIGHT COLSPAN=2><IMG SRC=hostTrafficDistrib-%s"CHART_FORMAT"?1></TD>",
 
2152
                    el->hostNumIpAddress[0] == '\0' ?  el->ethAddressString : el->hostNumIpAddress) < 0)
 
2153
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2154
        sendString(buf);
 
2155
      } else {
 
2156
        sendString("<TD "TH_BG" ALIGN=RIGHT COLSPAN=2>&nbsp;</TD>");
 
2157
      }
 
2158
 
 
2159
      if(totalReceived > 0) {
 
2160
        if(snprintf(buf, sizeof(buf),
 
2161
                    "<TD "TH_BG" ALIGN=RIGHT COLSPAN=2><IMG SRC=hostTrafficDistrib-%s"CHART_FORMAT"></TD>",
 
2162
                    el->hostNumIpAddress[0] == '\0' ?  el->ethAddressString : el->hostNumIpAddress) < 0)
 
2163
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2164
        sendString(buf);
 
2165
      } else {
 
2166
        sendString("<TD "TH_BG" ALIGN=RIGHT COLSPAN=2>&nbsp;</TD>");
 
2167
      }
 
2168
 
 
2169
 
 
2170
      sendString("</TD></TR>");
 
2171
    }
 
2172
  }
 
2173
#endif
 
2174
 
 
2175
#ifndef ENABLE_NAPSTER
 
2176
  a = b = 0;
 
2177
#else
 
2178
  if(el->napsterStats == NULL)
 
2179
    a = 0, b = 0;
 
2180
  else
 
2181
    a = el->napsterStats->bytesSent, b = el->napsterStats->bytesRcvd;
 
2182
#endif
 
2183
 
 
2184
  for(i=0; i<numIpProtosToMonitor; i++) {
 
2185
    a += el->protoIPTrafficInfos[i].sentLocally+
 
2186
      el->protoIPTrafficInfos[i].sentRemotely;
 
2187
    b += el->protoIPTrafficInfos[i].receivedLocally+
 
2188
      el->protoIPTrafficInfos[i].receivedFromRemote;
 
2189
  }
 
2190
 
 
2191
  if((a > 0) && (b > 0)) {
 
2192
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>IP Distribution</TH>"
 
2193
                "<TD "TH_BG" ALIGN=RIGHT COLSPAN=2><IMG SRC=hostIPTrafficDistrib-%s"CHART_FORMAT"?1>"
 
2194
                "</TD>"
 
2195
                "<TD "TH_BG" ALIGN=RIGHT COLSPAN=2><IMG SRC=hostIPTrafficDistrib-%s"CHART_FORMAT">"
 
2196
                "</TD></TR>",
 
2197
                getRowColor(),
 
2198
                el->hostNumIpAddress,
 
2199
                el->hostNumIpAddress) < 0)
 
2200
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2201
    sendString(buf);
 
2202
  }
 
2203
 
 
2204
  sendString("</TABLE>"TABLE_OFF"<P>\n");
 
2205
  sendString("</CENTER>\n");
 
2206
}
 
2207
 
 
2208
/* ************************************ */
 
2209
 
 
2210
void printHostContactedPeers(HostTraffic *el) {
 
2211
  u_int numEntries, i;
 
2212
  char buf[BUF_SIZE];
 
2213
 
 
2214
  if((el->pktSent != 0) || (el->pktReceived != 0)) {
 
2215
    int ok =0;
 
2216
 
 
2217
    for(numEntries = 0, i=0; i<MAX_NUM_CONTACTED_PEERS; i++)
 
2218
      if((el->contactedSentPeers.peersIndexes[i] != NO_PEER)
 
2219
         || (el->contactedRcvdPeers.peersIndexes[i] != NO_PEER)) {
 
2220
        ok = 1;
 
2221
        break;
 
2222
      }
 
2223
 
 
2224
    if(ok) {
 
2225
      struct hostTraffic *el1;
 
2226
 
 
2227
      printSectionTitle("Last Contacted Peers");
 
2228
      sendString("<CENTER>\n"
 
2229
                 "<TABLE BORDER=0 WIDTH=100%%><TR><TD "TD_BG" VALIGN=TOP>\n");
 
2230
 
 
2231
      for(numEntries = 0, i=0; i<MAX_NUM_CONTACTED_PEERS; i++)
 
2232
        if(el->contactedSentPeers.peersIndexes[i] != NO_PEER) {
 
2233
          el1 = device[actualReportDeviceId].hash_hostTraffic[
 
2234
                       checkSessionIdx(el->contactedSentPeers.peersIndexes[i])];
 
2235
 
 
2236
          if(el1 != NULL) {
 
2237
            if(numEntries == 0) {
 
2238
              sendString(""TABLE_ON"<TABLE BORDER=1 VALIGN=TOP WIDTH=100%%>"
 
2239
                         "<TR><TH "TH_BG">Receiver Name</TH>"
 
2240
                         "<TH "TH_BG">Receiver Address</TH></TR>\n");
 
2241
            }
 
2242
 
 
2243
            if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2244
                    "<TD "TD_BG"  ALIGN=CENTER>%s&nbsp;</TD></TR>\n",
 
2245
                    getRowColor(),
 
2246
                    makeHostLink(el1, 0, 0, 0),
 
2247
                    el1->hostNumIpAddress) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2248
 
 
2249
            sendString(buf);
 
2250
            numEntries++;
 
2251
          }
 
2252
        }
 
2253
 
 
2254
      if(numEntries > 0)
 
2255
        sendString("</TABLE>"TABLE_OFF"</TD><TD "TD_BG" VALIGN=TOP>\n");
 
2256
      else
 
2257
        sendString("&nbsp;</TD><TD "TD_BG">\n");
 
2258
 
 
2259
      /* ***************************************************** */
 
2260
      for(numEntries = 0, i=0; i<MAX_NUM_CONTACTED_PEERS; i++)
 
2261
        if(el->contactedRcvdPeers.peersIndexes[i] != NO_PEER) {
 
2262
          el1 = device[actualReportDeviceId].hash_hostTraffic[
 
2263
                       checkSessionIdx(el->contactedRcvdPeers.peersIndexes[i])];
 
2264
 
 
2265
          if(el1 != NULL) {
 
2266
            if(numEntries == 0) {
 
2267
              sendString(""TABLE_ON"<TABLE BORDER=1 WIDTH=100%%>"
 
2268
                         "<TR><TH "TH_BG">Sender Name</TH>"
 
2269
                         "<TH "TH_BG">Sender Address</TH></TR>\n");
 
2270
            }
 
2271
 
 
2272
            if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2273
                     "<TD "TD_BG"  ALIGN=CENTER>%s&nbsp;</TD></TR>\n",
 
2274
                    getRowColor(),
 
2275
                    makeHostLink(el1, 0, 0, 0),
 
2276
                    el1->hostNumIpAddress) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2277
 
 
2278
            sendString(buf);
 
2279
            numEntries++;
 
2280
          }
 
2281
        }
 
2282
 
 
2283
      if(numEntries > 0)
 
2284
        sendString("</TABLE>"TABLE_OFF"\n");
 
2285
 
 
2286
      sendString("</TD></TR></TABLE>"TABLE_OFF"<P>\n");
 
2287
      sendString("</CENTER>\n");
 
2288
    } /* ok */
 
2289
  }
 
2290
}
 
2291
 
 
2292
/* ************************************ */
 
2293
 
 
2294
/* Function below courtesy of Andreas Pfaller <a.pfaller@pop.gun.de> */
 
2295
 
 
2296
char *getSessionState(IPSession *session) {
 
2297
  switch (session->sessionState) {
 
2298
  case STATE_SYN:
 
2299
    return("Sent Syn");
 
2300
  case STATE_SYN_ACK:
 
2301
    return("Rcvd Syn/Ack");
 
2302
  case STATE_ACTIVE:
 
2303
    return("Active");
 
2304
  case STATE_FIN1_ACK0:
 
2305
    return("Fin1 Ack0");
 
2306
  case STATE_FIN1_ACK1:
 
2307
    return("Fin1 Ack1");
 
2308
  case STATE_FIN2_ACK0:
 
2309
    return("Fin2 Ack0");
 
2310
  case STATE_FIN2_ACK1:
 
2311
    return("Fin2 Ack1");
 
2312
  case STATE_FIN2_ACK2:
 
2313
    return("Fin2 Ack2");
 
2314
  case STATE_TIMEOUT:
 
2315
    return("Timeout");
 
2316
  case STATE_END:
 
2317
    return("End");
 
2318
  }
 
2319
 
 
2320
 return("*Unknown*");
 
2321
}
 
2322
 
 
2323
/* ************************************ */
 
2324
 
 
2325
void printHostSessions(HostTraffic *el, u_int elIdx) {
 
2326
  char buf[BUF_SIZE];
 
2327
  IpGlobalSession *scanner=NULL;
 
2328
  char *sessionType=NULL;
 
2329
  u_short numSessions;
 
2330
  u_int idx, i, sessionIdx;
 
2331
  static char _sport[8], _dport[8];
 
2332
 
 
2333
  for(sessionIdx=0; sessionIdx<2; sessionIdx++) {
 
2334
    if(sessionIdx == 0) {
 
2335
      if(el->tcpSessionList != NULL) {
 
2336
        printSectionTitle("TCP Session History");
 
2337
      }
 
2338
 
 
2339
      scanner = el->tcpSessionList;
 
2340
      sessionType = "TCP";
 
2341
    } else {
 
2342
      if(el->udpSessionList != NULL) {
 
2343
        printSectionTitle("UDP Session History");
 
2344
      }
 
2345
 
 
2346
      scanner = el->udpSessionList;
 
2347
      sessionType = "UDP";
 
2348
    }
 
2349
 
 
2350
    numSessions = 0;
 
2351
 
 
2352
    while(scanner != NULL) {
 
2353
      char *whoswho, *svc=NULL, tmpSvc[16];
 
2354
 
 
2355
      if(scanner->initiator == CLIENT_ROLE)
 
2356
        whoswho= "client";
 
2357
      else
 
2358
        whoswho= "server";
 
2359
 
 
2360
      if(sessionIdx == 0)
 
2361
        svc = getPortByNum((int)(scanner->port), IPPROTO_TCP);
 
2362
      else
 
2363
        svc = getPortByNum((int)(scanner->port), IPPROTO_UDP);
 
2364
 
 
2365
      if(svc == NULL) {
 
2366
        if(snprintf(tmpSvc, sizeof(tmpSvc), "%d", (int)(scanner->port)) < 0)
 
2367
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2368
        svc = tmpSvc;
 
2369
      }
 
2370
 
 
2371
      if(numSessions == 0) {
 
2372
        sendString("<CENTER>\n");
 
2373
        if(snprintf(buf, sizeof(buf), ""TABLE_ON"<TABLE BORDER=1 WIDTH=\"100%%\">\n<TR>"
 
2374
                    "<TH "TH_BG" COLSPAN=2>%s&nbsp;Service</TH>"
 
2375
                    "<TH "TH_BG">Role</TH><TH "TH_BG">"
 
2376
                    "#&nbsp;Sessions</TH>"
 
2377
                    "<TH "TH_BG">Bytes&nbsp;Sent</TH>"
 
2378
                    "<TH "TH_BG">Bytes&nbsp;Rcvd</TH>"
 
2379
                    "<TH "TH_BG">Last&nbsp;Seen</TH>"
 
2380
                    "<TH "TH_BG">First&nbsp;Seen</TH>"
 
2381
                    "<TH "TH_BG">Peers</TH></TR>\n",
 
2382
                    sessionType) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2383
        sendString(buf);
 
2384
      }
 
2385
 
 
2386
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=RIGHT>%s</TH>"
 
2387
                  "<TD "TD_BG"  ALIGN=CENTER>%d</TD>"
 
2388
                  "<TD "TD_BG"  ALIGN=CENTER>%s</TD><TD "TD_BG"  ALIGN=CENTER>%d"
 
2389
                  "</TD><TD "TD_BG"  ALIGN=CENTER>%s</TD>"
 
2390
                  "<TD "TD_BG"  ALIGN=CENTER>%s</TD><TD "TD_BG">"
 
2391
                  "%s</TD><TD "TD_BG">%s</TD>\n",
 
2392
                  getRowColor(), svc, scanner->port, whoswho,
 
2393
                  (int)scanner->sessionCounter,
 
2394
                  formatBytes(scanner->bytesSent, 1),
 
2395
                  formatBytes(scanner->bytesReceived, 1),
 
2396
                  formatTime(&(scanner->lastSeen), 1),
 
2397
                  formatTime(&(scanner->firstSeen), 1)
 
2398
                  ) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2399
      sendString(buf);
 
2400
      numSessions++;
 
2401
 
 
2402
      sendString("<TD "TD_BG"><UL>&nbsp;");
 
2403
      for(i=0; i < MAX_NUM_CONTACTED_PEERS; i++) {
 
2404
        u_int theIdx = scanner->peers.peersIndexes[i];
 
2405
 
 
2406
        if(theIdx != NO_PEER) {
 
2407
          HostTraffic *host = device[actualReportDeviceId].hash_hostTraffic[checkSessionIdx(theIdx)];
 
2408
        
 
2409
          if(host != NULL) {
 
2410
            sendString("\n<li>");
 
2411
            sendString(makeHostLink(host, 0, 0, 0));
 
2412
          }
 
2413
        }
 
2414
      }
 
2415
 
 
2416
      sendString("</UL></TR>\n");
 
2417
 
 
2418
      scanner = (IpGlobalSession*)(scanner->next);
 
2419
    }
 
2420
 
 
2421
    if(numSessions > 0) {
 
2422
      sendString("</TABLE>"TABLE_OFF"<P>\n");
 
2423
      sendString("</CENTER>\n");
 
2424
    }
 
2425
 
 
2426
    if(sessionIdx == 0) {
 
2427
      /* Now print currently established TCP sessions (if any) */
 
2428
      for(idx=1, numSessions=0; idx<device[actualReportDeviceId].numTotSessions; idx++)
 
2429
        if((device[actualReportDeviceId].tcpSession[idx] != NULL)
 
2430
           && ((device[actualReportDeviceId].tcpSession[idx]->initiatorIdx == elIdx)
 
2431
               || (device[actualReportDeviceId].tcpSession[idx]->remotePeerIdx == elIdx))
 
2432
#ifndef PRINT_ALL_ACTIVE_SESSIONS
 
2433
           && (device[actualReportDeviceId].tcpSession[idx]->sessionState == STATE_ACTIVE)
 
2434
#endif
 
2435
           ) {
 
2436
          char *sport, *dport, *remotePeer;
 
2437
          TrafficCounter dataSent, dataReceived, retrDataSent, retrDataRcvd;
 
2438
          TrafficCounter fragDataSent, fragDataRcvd;
 
2439
          int retrSentPercentage, retrRcvdPercentage;
 
2440
          char fragStrSent[64], fragStrRcvd[64], *moreSessionInfo;
 
2441
 
 
2442
          if(device[actualReportDeviceId].
 
2443
             tcpSession[idx]->remotePeerIdx == NO_PEER) /* This should not happen */
 
2444
            continue;
 
2445
 
 
2446
          if(numSessions == 0) {
 
2447
            printSectionTitle("Active TCP Sessions");
 
2448
            sendString("<CENTER>\n");
 
2449
            sendString(""TABLE_ON"<TABLE BORDER=1 WIDTH=\"100%%\"><TR>"
 
2450
                       "<TH "TH_BG">Local&nbsp;Port</TH>"
 
2451
                       "<TH "TH_BG">Remote&nbsp;Peer:Port</TH>"
 
2452
                       "<TH "TH_BG">Data&nbsp;Sent</TH>"
 
2453
#ifdef PRINT_RETRANSMISSION_DATA
 
2454
                       "<TH "TH_BG">Retran.&nbsp;Data&nbsp;Sent</TH>"
 
2455
#endif
 
2456
                       "<TH "TH_BG">Data&nbsp;Rcvd</TH>"
 
2457
#ifdef PRINT_RETRANSMISSION_DATA
 
2458
                       "<TH "TH_BG">Retran.&nbsp;Data&nbsp;Rcvd</TH>"
 
2459
#endif
 
2460
                       "<TH "TH_BG">Window&nbsp;Size</TH>"
 
2461
                       "<TH "TH_BG">Active&nbsp;Since</TH>"
 
2462
                       "<TH "TH_BG">Last&nbsp;Seen</TH>"
 
2463
                       "<TH "TH_BG">Duration</TH>"
 
2464
                       "<TH "TH_BG">Latency</TH>"
 
2465
#ifdef PRINT_ALL_ACTIVE_SESSIONS
 
2466
                       "<TH "TH_BG">State</TH>"
 
2467
#endif
 
2468
                       "</TR>\n");
 
2469
          }
 
2470
 
 
2471
          if(device[actualReportDeviceId].tcpSession[idx]->initiatorIdx == elIdx) {
 
2472
            sport = getPortByNum(device[actualReportDeviceId].tcpSession[idx]->sport, IPPROTO_TCP);
 
2473
            dport = getPortByNum(device[actualReportDeviceId].tcpSession[idx]->dport, IPPROTO_TCP);
 
2474
            if(sport == NULL) {
 
2475
              if(snprintf(_sport, sizeof(_sport), "%d",
 
2476
                          device[actualReportDeviceId].tcpSession[idx]->sport) < 0)
 
2477
                traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2478
              sport = _sport;
 
2479
            }
 
2480
 
 
2481
            if(dport == NULL) {
 
2482
              if(snprintf(_dport, sizeof(_dport), "%d",
 
2483
                          device[actualReportDeviceId].tcpSession[idx]->dport) < 0)
 
2484
                traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2485
              dport = _dport;
 
2486
            }
 
2487
            remotePeer = makeHostLink(device[actualReportDeviceId].
 
2488
                                      hash_hostTraffic[checkSessionIdx(device[actualReportDeviceId].
 
2489
                                                                       tcpSession[idx]->remotePeerIdx)],
 
2490
                                      SHORT_FORMAT, 0, 0);
 
2491
            dataSent     = device[actualReportDeviceId].tcpSession[idx]->bytesSent;
 
2492
            dataReceived = device[actualReportDeviceId].tcpSession[idx]->bytesReceived;
 
2493
            retrDataSent = device[actualReportDeviceId].tcpSession[idx]->bytesRetranI2R;
 
2494
            retrDataRcvd = device[actualReportDeviceId].tcpSession[idx]->bytesRetranR2I;
 
2495
            fragDataSent = device[actualReportDeviceId].tcpSession[idx]->bytesFragmentedSent;
 
2496
            fragDataRcvd = device[actualReportDeviceId].tcpSession[idx]->bytesFragmentedReceived;
 
2497
          } else {
 
2498
            /* Responder */
 
2499
            sport = getPortByNum(device[actualReportDeviceId].tcpSession[idx]->dport, IPPROTO_TCP);
 
2500
            dport = getPortByNum(device[actualReportDeviceId].tcpSession[idx]->sport, IPPROTO_TCP);
 
2501
            if(sport == NULL) {
 
2502
              if(snprintf(_sport, sizeof(_sport), "%d",
 
2503
                          device[actualReportDeviceId].tcpSession[idx]->dport) < 0)
 
2504
                traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2505
              sport = _sport;
 
2506
            }
 
2507
 
 
2508
            if(dport == NULL) {
 
2509
              if(snprintf(_dport, sizeof(_dport), "%d",
 
2510
                          device[actualReportDeviceId].tcpSession[idx]->sport) < 0)
 
2511
                traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2512
              dport = _dport;
 
2513
            }
 
2514
 
 
2515
            remotePeer = makeHostLink(device[actualReportDeviceId].
 
2516
                                      hash_hostTraffic[checkSessionIdx(device[actualReportDeviceId].
 
2517
                                                                       tcpSession[idx]->initiatorIdx)],
 
2518
                                      SHORT_FORMAT, 0, 0);
 
2519
            dataSent     = device[actualReportDeviceId].tcpSession[idx]->bytesReceived;
 
2520
            dataReceived = device[actualReportDeviceId].tcpSession[idx]->bytesSent;
 
2521
            retrDataSent = device[actualReportDeviceId].tcpSession[idx]->bytesRetranR2I;
 
2522
            retrDataRcvd = device[actualReportDeviceId].tcpSession[idx]->bytesRetranI2R;
 
2523
            fragDataSent = device[actualReportDeviceId].tcpSession[idx]->bytesFragmentedReceived;
 
2524
            fragDataRcvd = device[actualReportDeviceId].tcpSession[idx]->bytesFragmentedSent;
 
2525
          }
 
2526
 
 
2527
          /* Sanity check */
 
2528
          if((actTime < device[actualReportDeviceId].tcpSession[idx]->firstSeen)
 
2529
             || (device[actualReportDeviceId].tcpSession[idx]->firstSeen == 0))
 
2530
            device[actualReportDeviceId].tcpSession[idx]->firstSeen = actTime;
 
2531
 
 
2532
          retrSentPercentage = (int)((float)(retrDataSent*100))/((float)(dataSent+1));
 
2533
          retrRcvdPercentage = (int)((float)(retrDataRcvd*100))/((float)(dataReceived+1));
 
2534
 
 
2535
          if(fragDataSent == 0)
 
2536
            fragStrSent[0] = '\0';
 
2537
          else {
 
2538
            if(snprintf(fragStrSent, sizeof(fragStrSent), "(%.1f fragmented)",
 
2539
                        (int)((float)(fragDataSent*100))/((float)(dataSent+1))) < 0)
 
2540
              traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2541
          }
 
2542
          if(fragDataRcvd == 0)
 
2543
            fragStrRcvd[0] = '\0';
 
2544
          else {
 
2545
            if(snprintf(fragStrRcvd, sizeof(fragStrRcvd), "(%.1f fragmented)",
 
2546
                        (int)((float)(fragDataRcvd*100))/((float)(dataReceived+1))) < 0)
 
2547
              traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2548
          }
 
2549
 
 
2550
#ifndef ENABLE_NAPSTER
 
2551
          moreSessionInfo = "";
 
2552
#else
 
2553
          if(device[actualReportDeviceId].tcpSession[idx]->napsterSession)
 
2554
            moreSessionInfo = "&nbsp;[Napster]";
 
2555
          else
 
2556
            moreSessionInfo = "";
 
2557
#endif
 
2558
 
 
2559
          if(device[actualReportDeviceId].tcpSession[idx]->passiveFtpSession)
 
2560
            moreSessionInfo = "&nbsp;[FTP]";
 
2561
          else
 
2562
            moreSessionInfo = "";
 
2563
 
 
2564
          if(snprintf(buf, sizeof(buf), "<TR %s>"
 
2565
                      "<TD "TD_BG"  ALIGN=RIGHT>%s%s</TD>"
 
2566
                      "<TD "TD_BG"  ALIGN=RIGHT>%s:%s</TD>"
 
2567
                      "<TD "TD_BG"  ALIGN=RIGHT>%s %s</TD>"
 
2568
#ifdef PRINT_RETRANSMISSION_DATA
 
2569
                      "<TD "TD_BG"  ALIGN=RIGHT>%s [%d%%]</TD>"
 
2570
#endif
 
2571
                      "<TD "TD_BG"  ALIGN=RIGHT>%s %s</TD>"
 
2572
#ifdef PRINT_RETRANSMISSION_DATA
 
2573
                      "<TD "TD_BG"  ALIGN=RIGHT>%s [%d%%]</TD>"
 
2574
#endif
 
2575
                      , getRowColor(),
 
2576
                      sport, moreSessionInfo,
 
2577
                      remotePeer, dport,
 
2578
                      formatBytes(dataSent, 1), fragStrSent,
 
2579
#ifdef PRINT_RETRANSMISSION_DATA
 
2580
                      formatBytes(retrDataSent, 1),
 
2581
                      retrSentPercentage,
 
2582
#endif
 
2583
                      formatBytes(dataReceived, 1), fragStrRcvd
 
2584
#ifdef PRINT_RETRANSMISSION_DATA
 
2585
                      , formatBytes(retrDataRcvd, 1),
 
2586
                      retrRcvdPercentage
 
2587
#endif
 
2588
                      ) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2589
 
 
2590
          sendString(buf);
 
2591
 
 
2592
          if(snprintf(buf, sizeof(buf),
 
2593
                      "<TD "TD_BG"  ALIGN=CENTER NOWRAP>%d:%d</TD>"
 
2594
                      "<TD "TD_BG"  ALIGN=RIGHT>%s</TD>"
 
2595
                      "<TD "TD_BG"  ALIGN=RIGHT>%s</TD>"
 
2596
                      "<TD "TD_BG"  ALIGN=RIGHT>%s</TD>"
 
2597
                      "<TD "TD_BG"  ALIGN=RIGHT>%s</TD>"
 
2598
#ifdef PRINT_ALL_ACTIVE_SESSIONS
 
2599
                      "<TD "TD_BG"  ALIGN=CENTER>%s</TD>"
 
2600
#endif
 
2601
                      "</TR>\n",
 
2602
                      device[actualReportDeviceId].tcpSession[idx]->minWindow,
 
2603
                      device[actualReportDeviceId].tcpSession[idx]->maxWindow,
 
2604
                      formatTime(&(device[actualReportDeviceId].tcpSession[idx]->firstSeen), 1),
 
2605
                      formatTime(&(device[actualReportDeviceId].tcpSession[idx]->lastSeen), 1),
 
2606
                      formatSeconds(actTime-device[actualReportDeviceId].tcpSession[idx]->firstSeen),
 
2607
                      formatLatency(device[actualReportDeviceId].tcpSession[idx]->nwLatency,
 
2608
                                    device[actualReportDeviceId].tcpSession[idx]->sessionState)
 
2609
#ifdef PRINT_ALL_ACTIVE_SESSIONS
 
2610
                      , getSessionState(device[actualReportDeviceId].tcpSession[idx])
 
2611
#endif
 
2612
                      ) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2613
 
 
2614
          sendString(buf);
 
2615
 
 
2616
          numSessions++;
 
2617
        }
 
2618
 
 
2619
      if(numSessions > 0) {
 
2620
        sendString("</TABLE>"TABLE_OFF"<P>\n");
 
2621
        sendString("</CENTER>\n");
 
2622
      }
 
2623
    }
 
2624
  }
 
2625
}
 
2626
 
 
2627
/* ******************************* */
 
2628
/*
 
2629
   Return codes:
 
2630
 
 
2631
   OK          0
 
2632
   Warning     1
 
2633
   Error       2!
 
2634
*/
 
2635
 
 
2636
u_short isHostHealthy(HostTraffic *el) {
 
2637
  u_char riskFactor = 0;
 
2638
 
 
2639
  if(hasWrongNetmask(el)) {
 
2640
    if(riskFactor < 1) riskFactor = 1;
 
2641
  }
 
2642
 
 
2643
  if(hasDuplicatedMac(el)) {
 
2644
    if(riskFactor < 2) riskFactor = 2;
 
2645
  }
 
2646
 
 
2647
  return(riskFactor);
 
2648
}
 
2649
 
 
2650
/* ************************************ */
 
2651
 
 
2652
static void checkHostHealthness(HostTraffic *el) {
 
2653
  char buf[BUF_SIZE];
 
2654
 
 
2655
  if(hasWrongNetmask(el)
 
2656
     || hasDuplicatedMac(el)
 
2657
     ) {
 
2658
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s "
 
2659
                "<IMG ALT=\"High Risk\" SRC=/Risk_high.gif> "
 
2660
                "<IMG ALT=\"Medium Risk\" SRC=/Risk_medium.gif> "
 
2661
                "<IMG  ALT=\"Low Risk\" SRC=/Risk_low.gif>"
 
2662
                "</TH><TD "TD_BG" ALIGN=RIGHT NOWRAP><OL>", getRowColor(),
 
2663
                "Network Healthness") < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2664
    sendString(buf);
 
2665
 
 
2666
    if(hasWrongNetmask(el))
 
2667
      sendString("<LI><IMG ALT=\"Medium Risk\" SRC=/Risk_medium.gif><A HREF=/help.html#1>"
 
2668
                 "Wrong network mask or bridging enabled</A>\n");
 
2669
 
 
2670
    if(hasDuplicatedMac(el))
 
2671
      sendString("<LI><IMG ALT=\"High Risk\" SRC=/Risk_high.gif><A HREF=/help.html#2>"
 
2672
                 "Duplicated MAC found for this IP address (spoofing?)</A>\n");
 
2673
 
 
2674
    sendString("</OL></TD></TR>\n");
 
2675
  }
 
2676
}
 
2677
 
 
2678
/* ************************************ */
 
2679
 
 
2680
void checkHostProvidedServices(HostTraffic *el) {
 
2681
  char buf[BUF_SIZE];
 
2682
 
 
2683
  if(isServer(el)
 
2684
     || isWorkstation(el)
 
2685
     || isMasterBrowser(el)
 
2686
     || isPrinter(el)
 
2687
     || isBridgeHost(el)
 
2688
     || nameServerHost(el)
 
2689
     || gatewayHost(el)
 
2690
     || isSMTPhost(el) || isIMAPhost(el) || isPOPhost(el)
 
2691
     || isDirectoryHost(el)
 
2692
     || isFTPhost(el)
 
2693
     || isHTTPhost(el)
 
2694
     || isWINShost(el)
 
2695
#ifdef ENABLE_NAPSTER
 
2696
     || isNapsterRedirector(el) || isNapsterServer(el) || isNapsterClient(el)
 
2697
#endif
 
2698
     || isDHCPClient(el)        || isDHCPServer(el)
 
2699
     ) {
 
2700
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2701
                "<TD "TD_BG"  ALIGN=RIGHT>", getRowColor(),
 
2702
                "Host Type") < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2703
    sendString(buf);
 
2704
 
 
2705
    if(isServer(el))           sendString("Server<br>");
 
2706
    if(isWorkstation(el))      sendString("Workstation<br>");
 
2707
    if(isMasterBrowser(el))    sendString("Master Browser<br>");
 
2708
    if(isPrinter(el))          sendString("Printer&nbsp;<IMG ALT=Printer SRC=printer.gif BORDER=0><br>");
 
2709
    if(isBridgeHost(el))       sendString("Bridge<br>");
 
2710
 
 
2711
    if(nameServerHost(el))     sendString("&nbsp;<IMG ALT=\"DNS Server\" SRC=/dns.gif BORDER=0>&nbsp;Name Server<br>");
 
2712
    if(gatewayHost(el))        sendString("Gateway&nbsp;<IMG ALT=Router SRC=/router.gif BORDER=0>&nbsp;<br>");
 
2713
    if(isSMTPhost(el))         sendString("SMTP Server&nbsp;<IMG ALT=\"Mail Server (SMTP)\"  SRC=/mail.gif BORDER=0>&nbsp;<br>");
 
2714
    if(isPOPhost(el))          sendString("POP Server<br>");
 
2715
    if(isIMAPhost(el))         sendString("IMAP Server<br>");
 
2716
    if(isDirectoryHost(el))    sendString("Directory Server<br>");
 
2717
    if(isFTPhost(el))          sendString("FTP Server<br>");
 
2718
    if(isHTTPhost(el))         sendString("HTTP Server<br>");
 
2719
    if(isWINShost(el))         sendString("WINS Server<br>");
 
2720
 
 
2721
 
 
2722
#ifdef ENABLE_NAPSTER
 
2723
    if(isNapsterRedirector(el))   sendString("Napster Redirector<br>");
 
2724
    if(isNapsterServer(el))       sendString("Napster Server<br>");
 
2725
    if(isNapsterClient(el))       sendString("Napster Client<br>");
 
2726
#endif
 
2727
 
 
2728
    if(isDHCPClient(el))          sendString("BOOTP/DHCP Client&nbsp;<IMG ALT=\"DHCP Client\" SRC=/bulb.gif BORDER=0><br>");
 
2729
    if(isDHCPServer(el))          sendString("BOOTP/DHCP Server&nbsp;<IMG ALT=\"DHCP Server\" SRC=/wheel.gif BORDER=0>&nbsp;<br>");
 
2730
    sendString("</TD></TR>");
 
2731
  }
 
2732
}
 
2733
 
 
2734
/* ************************************ */
 
2735
 
 
2736
void printHostDetailedInfo(HostTraffic *el) {
 
2737
  char buf[BUF_SIZE], buf1[64], sniffedName[MAXDNAME];
 
2738
  float percentage;
 
2739
  TrafficCounter total;
 
2740
  int printedHeader, i;
 
2741
  char *dynIp, *multihomed;
 
2742
 
 
2743
#ifdef MULTITHREADED
 
2744
  accessMutex(&addressResolutionMutex, "printAllSessionsHTML");
 
2745
#endif
 
2746
 
 
2747
  buf1[0]=0;
 
2748
  if(getSniffedDNSName(el->hostNumIpAddress, sniffedName, sizeof(sniffedName))) {
 
2749
    if(el->hostSymIpAddress[0] == '\0' || strcmp(sniffedName, el->hostSymIpAddress))
 
2750
      snprintf(buf1, sizeof(buf1), " (%s)", sniffedName);
 
2751
  }
 
2752
 
 
2753
  if(el->hostSymIpAddress[0] == '\0') {
 
2754
    if(snprintf(buf, sizeof(buf), "Info about host %s",
 
2755
            el->ethAddressString) < 0)
 
2756
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2757
  } else {
 
2758
    if(el->hostNumIpAddress[0] == '\0') {
 
2759
    if(snprintf(buf, sizeof(buf), "Info about host %s", el->hostSymIpAddress) < 0)
 
2760
      traceEvent(TRACE_ERROR, "Buffer overflow!");    
 
2761
    } else {
 
2762
      if(snprintf(buf, sizeof(buf), "Info about host"
 
2763
                  " <A HREF=http://%s/>%s %s</A>\n",
 
2764
                  el->hostNumIpAddress, el->hostSymIpAddress, buf1) < 0)
 
2765
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2766
    }
 
2767
  }
 
2768
 
 
2769
#ifdef MULTITHREADED
 
2770
  releaseMutex(&addressResolutionMutex);
 
2771
#endif
 
2772
 
 
2773
  printHTMLheader(buf, 0);
 
2774
  sendString("<CENTER>\n");
 
2775
  sendString("<P>"TABLE_ON"<TABLE BORDER=1 WIDTH=\"100%%\">\n");
 
2776
 
 
2777
  if(el->hostNumIpAddress[0] != '\0') {
 
2778
    char *countryIcon, *hostType;
 
2779
 
 
2780
#ifdef MULTITHREADED
 
2781
    accessMutex(&addressResolutionMutex, "printAllSessions-2");
 
2782
#endif
 
2783
 
 
2784
    /* Courtesy of Roberto De Luca <deluca@tandar.cnea.gov.ar> */
 
2785
    if(strcmp(el->hostNumIpAddress, el->hostSymIpAddress) != 0) {
 
2786
#ifdef MULTITHREADED
 
2787
      releaseMutex(&addressResolutionMutex);
 
2788
#endif
 
2789
      countryIcon = getHostCountryIconURL(el);
 
2790
    } else {
 
2791
#ifdef MULTITHREADED
 
2792
      releaseMutex(&addressResolutionMutex);
 
2793
#endif
 
2794
      countryIcon = "";
 
2795
    }
 
2796
 
 
2797
    if(broadcastHost(el)) hostType = "broadcast";
 
2798
    else if(multicastHost(el)) hostType = "multicast";
 
2799
    else hostType = "unicast";
 
2800
 
 
2801
    if(isDHCPClient(el))
 
2802
      dynIp = "/dynamic";
 
2803
    else
 
2804
      dynIp = "";
 
2805
 
 
2806
    if(isMultihomed(el) && (!broadcastHost(el)))
 
2807
      multihomed = "&nbsp;-&nbsp;multihomed&nbsp;<IMG ALT=\"Multihomed Host SRC=/multihomed.gif BORDER=0>";
 
2808
    else
 
2809
      multihomed = "";
 
2810
 
 
2811
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2812
                "<TD "TD_BG"  ALIGN=RIGHT>%s&nbsp;%s&nbsp;[%s%s%s]",
 
2813
                getRowColor(),
 
2814
                "IP&nbsp;Address",
 
2815
                el->hostNumIpAddress,
 
2816
                countryIcon, hostType, dynIp, multihomed) < 0)
 
2817
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2818
    sendString(buf);
 
2819
 
 
2820
    sendString("</TD></TR>\n");
 
2821
 
 
2822
    if(isMultihomed(el) && (!broadcastHost(el))) {
 
2823
      u_int elIdx;
 
2824
 
 
2825
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD ALIGN=RIGHT><OL>",
 
2826
                  getRowColor(), "Multihomed Addresses") < 0)
 
2827
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2828
      sendString(buf);
 
2829
 
 
2830
      for(elIdx=1; elIdx<device[actualReportDeviceId].actualHashSize; elIdx++) {
 
2831
        HostTraffic *theHost;
 
2832
 
 
2833
        if(elIdx == otherHostEntryIdx) continue;
 
2834
 
 
2835
        theHost = device[actualReportDeviceId].hash_hostTraffic[elIdx];
 
2836
 
 
2837
        if((theHost != NULL)
 
2838
           && (theHost != el)
 
2839
           && (memcmp(theHost->ethAddress, el->ethAddress, ETHERNET_ADDRESS_LEN) == 0)) {
 
2840
          if(snprintf(buf, sizeof(buf), "<LI><A HREF=/%s.html>%s</A>",
 
2841
                      theHost->hostNumIpAddress, theHost->hostNumIpAddress) < 0)
 
2842
            traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2843
          sendString(buf);
 
2844
        }
 
2845
      }
 
2846
      
 
2847
      sendString("</TD></TR>");
 
2848
    }
 
2849
 
 
2850
    if(el->dhcpStats != NULL) {
 
2851
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>",
 
2852
                  getRowColor(), "DHCP Information") < 0)
 
2853
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2854
      sendString(buf);
 
2855
 
 
2856
      sendString("<TD "TD_BG"><TABLE BORDER WIDTH=100%%>\n");
 
2857
 
 
2858
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2859
                  "<TD ALIGN=RIGHT COLSPAN=2>%s</TD></TR>\n", getRowColor(), "DHCP Server",
 
2860
                  _intoa(el->dhcpStats->dhcpServerIpAddress, buf1, sizeof(buf1))) < 0)
 
2861
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2862
      sendString(buf);
 
2863
 
 
2864
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2865
                  "<TD ALIGN=RIGHT COLSPAN=2>%s</TD></TR>\n", getRowColor(), "Previous IP Address",
 
2866
                  _intoa(el->dhcpStats->previousIpAddress, buf1, sizeof(buf1))) < 0)
 
2867
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2868
      sendString(buf);
 
2869
 
 
2870
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2871
                  "<TD ALIGN=RIGHT COLSPAN=2>%s</TD></TR>\n",
 
2872
                  getRowColor(), "Address Assigned on",
 
2873
                  formatTime(&(el->dhcpStats->assignTime), 1)) < 0)
 
2874
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2875
      sendString(buf);
 
2876
 
 
2877
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2878
                  "<TD ALIGN=RIGHT COLSPAN=2>%s</TD></TR>\n",
 
2879
                  getRowColor(), "To be Renewed Before",
 
2880
                  formatTime(&(el->dhcpStats->renewalTime), 1)) < 0)
 
2881
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2882
      sendString(buf);
 
2883
 
 
2884
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2885
                  "<TD ALIGN=RIGHT COLSPAN=2>%s</TD></TR>\n",
 
2886
                  getRowColor(), "Lease Ends on",
 
2887
                  formatTime(&(el->dhcpStats->leaseTime), 1)) < 0)
 
2888
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2889
      sendString(buf);
 
2890
 
 
2891
 
 
2892
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>DHCP Packets</TH>"
 
2893
                  "<TH "TH_BG" ALIGN=CENTER>Sent</TH><TH "TH_BG" ALIGN=RIGHT>Rcvd</TH></TR>\n",
 
2894
                  getRowColor()) < 0)
 
2895
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2896
      sendString(buf);
 
2897
 
 
2898
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2899
                  "<TD ALIGN=RIGHT>%s</TD><TD ALIGN=RIGHT>%s</TD></TR>\n",
 
2900
                  getRowColor(), "DHCP Discover",
 
2901
                  formatPkts(el->dhcpStats->dhcpMsgSent[DHCP_DISCOVER_MSG]),
 
2902
                  formatPkts(el->dhcpStats->dhcpMsgRcvd[DHCP_DISCOVER_MSG])) < 0)
 
2903
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2904
      sendString(buf);
 
2905
 
 
2906
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2907
                  "<TD ALIGN=RIGHT>%s</TD><TD ALIGN=RIGHT>%s</TD></TR>\n",
 
2908
                  getRowColor(), "DHCP Offer",
 
2909
                  formatPkts(el->dhcpStats->dhcpMsgSent[DHCP_OFFER_MSG]),
 
2910
                  formatPkts(el->dhcpStats->dhcpMsgRcvd[DHCP_OFFER_MSG])) < 0)
 
2911
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2912
      sendString(buf);
 
2913
 
 
2914
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2915
                  "<TD ALIGN=RIGHT>%s</TD><TD ALIGN=RIGHT>%s</TD></TR>\n",
 
2916
                  getRowColor(), "DHCP Request",
 
2917
                  formatPkts(el->dhcpStats->dhcpMsgSent[DHCP_REQUEST_MSG]),
 
2918
                  formatPkts(el->dhcpStats->dhcpMsgRcvd[DHCP_REQUEST_MSG])) < 0)
 
2919
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2920
      sendString(buf);
 
2921
 
 
2922
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2923
                  "<TD ALIGN=RIGHT>%s</TD><TD ALIGN=RIGHT>%s</TD></TR>\n",
 
2924
                  getRowColor(), "DHCP Decline",
 
2925
                  formatPkts(el->dhcpStats->dhcpMsgSent[DHCP_DECLINE_MSG]),
 
2926
                  formatPkts(el->dhcpStats->dhcpMsgRcvd[DHCP_DECLINE_MSG])) < 0)
 
2927
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2928
      sendString(buf);
 
2929
 
 
2930
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2931
                  "<TD ALIGN=RIGHT>%s</TD><TD ALIGN=RIGHT>%s</TD></TR>\n",
 
2932
                  getRowColor(), "DHCP Ack",
 
2933
                  formatPkts(el->dhcpStats->dhcpMsgSent[DHCP_ACK_MSG]),
 
2934
                  formatPkts(el->dhcpStats->dhcpMsgRcvd[DHCP_ACK_MSG])) < 0)
 
2935
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2936
      sendString(buf);
 
2937
 
 
2938
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2939
                  "<TD ALIGN=RIGHT>%s</TD><TD ALIGN=RIGHT>%s</TD></TR>\n",
 
2940
                  getRowColor(), "DHCP Nack",
 
2941
                  formatPkts(el->dhcpStats->dhcpMsgSent[DHCP_NACK_MSG]),
 
2942
                  formatPkts(el->dhcpStats->dhcpMsgRcvd[DHCP_NACK_MSG])) < 0)
 
2943
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2944
      sendString(buf);
 
2945
 
 
2946
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2947
                  "<TD ALIGN=RIGHT>%s</TD><TD ALIGN=RIGHT>%s</TD></TR>\n",
 
2948
                  getRowColor(), "DHCP Release",
 
2949
                  formatPkts(el->dhcpStats->dhcpMsgSent[DHCP_RELEASE_MSG]),
 
2950
                  formatPkts(el->dhcpStats->dhcpMsgRcvd[DHCP_RELEASE_MSG])) < 0)
 
2951
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2952
      sendString(buf);
 
2953
 
 
2954
 
 
2955
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2956
                  "<TD ALIGN=RIGHT>%s</TD><TD ALIGN=RIGHT>%s</TD></TR>\n",
 
2957
                  getRowColor(), "DHCP Inform",
 
2958
                  formatPkts(el->dhcpStats->dhcpMsgSent[DHCP_INFORM_MSG]),
 
2959
                  formatPkts(el->dhcpStats->dhcpMsgRcvd[DHCP_INFORM_MSG])) < 0)
 
2960
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2961
      sendString(buf);
 
2962
 
 
2963
 
 
2964
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2965
                  "<TD ALIGN=RIGHT>%s</TD><TD ALIGN=RIGHT>%s</TD></TR>\n",
 
2966
                  getRowColor(), "DHCP Unknown Msg",
 
2967
                  formatPkts(el->dhcpStats->dhcpMsgSent[DHCP_UNKNOWN_MSG]),
 
2968
                  formatPkts(el->dhcpStats->dhcpMsgRcvd[DHCP_UNKNOWN_MSG])) < 0)
 
2969
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2970
      sendString(buf);
 
2971
 
 
2972
      sendString("</TABLE></TD></TR>\n");
 
2973
    }
 
2974
  }
 
2975
 
 
2976
  if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
2977
              "<TD "TD_BG"  ALIGN=RIGHT>"
 
2978
          "%s&nbsp;&nbsp;-&nbsp;&nbsp;%s&nbsp;[%s]</TD></TR>\n",
 
2979
           getRowColor(),
 
2980
           "First/Last&nbsp;Seen",
 
2981
           formatTime(&(el->firstSeen), 1),
 
2982
           formatTime(&(el->lastSeen), 1),
 
2983
           formatSeconds(el->lastSeen - el->firstSeen)) < 0)
 
2984
    traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2985
  sendString(buf);
 
2986
 
 
2987
  if(el->fullDomainName && (el->fullDomainName[0] != '\0')) {
 
2988
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
2989
            "%s</TD></TR>\n",
 
2990
            getRowColor(),
 
2991
            "Domain", el->fullDomainName) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
2992
    sendString(buf);
 
2993
  }
 
2994
 
 
2995
  if((el->ethAddressString[0] != '\0')
 
2996
     && strcmp(el->ethAddressString, "00:00:00:00:00:00")
 
2997
     && strcmp(el->ethAddressString, "00:01:02:03:04:05") /* dummy address */) {
 
2998
    char *vendorName;
 
2999
 
 
3000
    if(isMultihomed(el)) {
 
3001
      char *symMacAddr, symLink[32];
 
3002
      int i;
 
3003
 
 
3004
      symMacAddr = etheraddr_string(el->ethAddress);
 
3005
      strcpy(symLink, symMacAddr);
 
3006
      for(i=0; symLink[i] != '\0'; i++)
 
3007
        if(symLink[i] == ':')
 
3008
          symLink[i] = '_';
 
3009
 
 
3010
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG" ALIGN=RIGHT>"
 
3011
                  "<A HREF=%s.html>%s</A>%s</TD></TR>\n",
 
3012
                  getRowColor(), "Main Host MAC Address",
 
3013
                  symLink, symMacAddr,
 
3014
                  separator /* it avoids empty cells not to be rendered */) < 0)
 
3015
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3016
      sendString(buf);
 
3017
 
 
3018
    } else {
 
3019
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3020
                  "%s%s</TD></TR>\n",
 
3021
                  getRowColor(), "MAC&nbsp;Address <IMG ALT=\"Network Interface Card (NIC)\" SRC=/card.gif BORDER=0>",
 
3022
                  el->ethAddressString,
 
3023
                  separator /* it avoids empty cells not to be rendered */) < 0)
 
3024
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3025
      sendString(buf);
 
3026
    }
 
3027
 
 
3028
    vendorName = getVendorInfo(el->ethAddress, 1);
 
3029
    if(vendorName[0] != '\0') {
 
3030
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3031
              "%s%s</TD></TR>\n",
 
3032
              getRowColor(), "Nw&nbsp;Board&nbsp;Vendor",
 
3033
              vendorName,
 
3034
              separator /* it avoids empty cells not to be rendered */) < 0)
 
3035
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3036
      sendString(buf);
 
3037
    }
 
3038
  }
 
3039
 
 
3040
  if(((el->lastEthAddress[0] != 0)
 
3041
      || (el->lastEthAddress[1] != 0)
 
3042
      || (el->lastEthAddress[2] != 0)
 
3043
      || (el->lastEthAddress[3] != 0)
 
3044
      || (el->lastEthAddress[4] != 0)
 
3045
      || (el->lastEthAddress[5] != 0) /* The address isn't empty */)
 
3046
     && (memcmp(el->lastEthAddress, el->ethAddress, ETHERNET_ADDRESS_LEN) != 0)) {
 
3047
    /* Different MAC addresses */
 
3048
    char *symMacAddr, symLink[32];
 
3049
    int i;
 
3050
 
 
3051
    symMacAddr = etheraddr_string(el->lastEthAddress);
 
3052
    strcpy(symLink, symMacAddr);
 
3053
    for(i=0; symLink[i] != '\0'; i++)
 
3054
      if(symLink[i] == ':')
 
3055
        symLink[i] = '_';
 
3056
 
 
3057
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG" ALIGN=RIGHT>"
 
3058
                "<A HREF=%s.html>%s</A>%s</TD></TR>\n",
 
3059
                getRowColor(), "Last MAC Address/Router <IMG ALT=\"Network Interface Card (NIC)/Router\" SRC=/card.gif BORDER=0>",
 
3060
                symLink, symMacAddr,
 
3061
                separator /* it avoids empty cells not to be rendered */) < 0)
 
3062
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3063
    sendString(buf);
 
3064
  }
 
3065
 
 
3066
  if(el->hostNumIpAddress[0] != '\0') {
 
3067
    updateOSName(el);
 
3068
 
 
3069
    if((el->osName != NULL) && (el->osName[0] != '\0')) {
 
3070
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3071
                  "%s%s</TD></TR>\n",
 
3072
                  getRowColor(), "OS&nbsp;Name",
 
3073
                  getOSFlag(el->osName, 1),
 
3074
                  separator /* it avoids empty cells not to be rendered */) < 0)
 
3075
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3076
      sendString(buf);
 
3077
    }
 
3078
  }
 
3079
 
 
3080
  if((el->nbHostName != NULL) && (el->nbDomainName != NULL)) {
 
3081
    if(el->nbAccountName) {
 
3082
      if(el->nbDomainName != NULL) {
 
3083
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3084
                  "%s@%s&nbsp;[domain %s] (%s) %s</TD></TR>\n",
 
3085
                  getRowColor(), "NetBios&nbsp;Name",
 
3086
                  el->nbAccountName, el->nbHostName, el->nbDomainName,
 
3087
                  getNbNodeType(el->nbNodeType),
 
3088
                  el->nbDescr ? el->nbDescr : "") < 0)
 
3089
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3090
      } else {
 
3091
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3092
                  "%s@%s (%s) %s</TD></TR>\n",
 
3093
                  getRowColor(), "NetBios&nbsp;Name",
 
3094
                  el->nbAccountName, el->nbHostName,
 
3095
                  getNbNodeType(el->nbNodeType),
 
3096
                  el->nbDescr ? el->nbDescr : "") < 0)
 
3097
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3098
      }
 
3099
    } else {
 
3100
      if(el->nbDomainName != NULL) {
 
3101
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3102
                  "%s&nbsp;[domain %s] (%s) %s</TD></TR>\n",
 
3103
                  getRowColor(), "NetBios&nbsp;Name",
 
3104
                  el->nbHostName, el->nbDomainName,
 
3105
                  getNbNodeType(el->nbNodeType),
 
3106
                  el->nbDescr ? el->nbDescr : "") < 0)
 
3107
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3108
      } else {
 
3109
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3110
                  "%s (%s) %s</TD></TR>\n",
 
3111
                  getRowColor(), "NetBios&nbsp;Name",
 
3112
                  el->nbHostName,
 
3113
                  getNbNodeType(el->nbNodeType),
 
3114
                  el->nbDescr ? el->nbDescr : "") < 0)
 
3115
        traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3116
      }
 
3117
    }
 
3118
 
 
3119
    sendString(buf);
 
3120
  } else if(el->nbHostName != NULL) {
 
3121
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3122
                "%s&nbsp;(%s) %s</TD></TR>\n",
 
3123
                getRowColor(), "NetBios&nbsp;Name",
 
3124
                el->nbHostName, getNbNodeType(el->nbNodeType),
 
3125
                el->nbDescr ? el->nbDescr : "") < 0)
 
3126
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3127
    sendString(buf);
 
3128
  }
 
3129
 
 
3130
  if(el->atNetwork != 0) {
 
3131
    char *nodeName = el->atNodeName;
 
3132
 
 
3133
    if(nodeName == NULL) nodeName = "";
 
3134
 
 
3135
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3136
            "%s&nbsp;\n",
 
3137
            getRowColor(), "AppleTalk&nbsp;Name",
 
3138
            nodeName) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3139
    sendString(buf);
 
3140
 
 
3141
    if(el->atNodeType[0] != NULL) {
 
3142
      int i;
 
3143
 
 
3144
      sendString("(");
 
3145
      for(i=0; i<MAX_NODE_TYPES; i++)
 
3146
        if(el->atNodeType[i] == NULL)
 
3147
          break;
 
3148
        else {
 
3149
          if(i > 0) sendString("/");
 
3150
          sendString(el->atNodeType[i]);
 
3151
        }
 
3152
 
 
3153
      sendString(")&nbsp;");
 
3154
    }
 
3155
 
 
3156
    if(snprintf(buf, sizeof(buf), "[%d.%d]</TD></TR>\n",
 
3157
             el->atNetwork, el->atNode) < 0)
 
3158
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3159
    sendString(buf);
 
3160
  }
 
3161
 
 
3162
  if(el->ipxHostName != NULL) {
 
3163
    int i;
 
3164
 
 
3165
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH>"
 
3166
                "<TD "TD_BG"  ALIGN=RIGHT>"
 
3167
             "%s&nbsp;[", getRowColor(), "IPX&nbsp;Name",
 
3168
             el->ipxHostName) < 0)
 
3169
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3170
    sendString(buf);
 
3171
 
 
3172
    for(i=0; i<el->numIpxNodeTypes; i++) {
 
3173
      if(i>0) sendString("/");
 
3174
      sendString(getSAPInfo(el->ipxNodeType[i], 1));
 
3175
    }
 
3176
 
 
3177
    sendString("]</TD></TR>\n");
 
3178
  }
 
3179
 
 
3180
  if(!multicastHost(el)) {
 
3181
    if(subnetPseudoLocalHost(el)) {
 
3182
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3183
              "%s</TD></TR>\n", getRowColor(),
 
3184
              "Host&nbsp;Location",
 
3185
              "Local (inside specified/local subnet)") < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3186
    } else {
 
3187
      if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3188
              "%s</TD></TR>\n", getRowColor(),
 
3189
              "Host&nbsp;Location",
 
3190
              "Remote (outside specified/local subnet)") < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3191
    }
 
3192
    sendString(buf);
 
3193
  }
 
3194
 
 
3195
  if(el->minTTL > 0) {
 
3196
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3197
                "%d:%d&nbsp;hops</TD></TR>\n",
 
3198
                getRowColor(), "IP&nbsp;TTL&nbsp;(Time to Live)",
 
3199
                el->minTTL, el->maxTTL) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3200
    sendString(buf);
 
3201
  }
 
3202
 
 
3203
  if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3204
              "%s/%s Pkts/%s Retran. Pkts [%d%%]</TD></TR>\n",
 
3205
              getRowColor(), "Total&nbsp;Data&nbsp;Sent",
 
3206
              formatBytes(el->bytesSent, 1), formatPkts(el->pktSent),
 
3207
              formatPkts(el->pktDuplicatedAckSent),
 
3208
              (int)(((float)el->pktDuplicatedAckSent*100)/(float)(el->pktSent+1))
 
3209
              ) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3210
  sendString(buf);
 
3211
 
 
3212
  if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3213
          "%s Pkts</TD></TR>\n",
 
3214
          getRowColor(), "Broadcast&nbsp;Pkts&nbsp;Sent",
 
3215
          formatPkts(el->pktBroadcastSent)) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3216
  sendString(buf);
 
3217
 
 
3218
  if(el->routedTraffic != NULL) {
 
3219
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3220
                "%s/%s Pkts</TD></TR>\n",
 
3221
                getRowColor(), "Routed Traffic",
 
3222
                formatBytes(el->routedTraffic->routedBytes, 1),
 
3223
                formatPkts(el->routedTraffic->routedPkts)) < 0)
 
3224
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3225
    sendString(buf);    
 
3226
  }
 
3227
 
 
3228
  if((el->pktMulticastSent > 0) || (el->pktMulticastRcvd > 0)) {
 
3229
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3230
            "Sent&nbsp;%s/%s&nbsp;Pkts&nbsp;-"
 
3231
            "&nbsp;Rcvd&nbsp;%s/%s&nbsp;Pkts</TD></TR>\n",
 
3232
            getRowColor(), "Multicast&nbsp;Traffic",
 
3233
            formatBytes(el->bytesMulticastSent, 1),
 
3234
            formatPkts(el->pktMulticastSent),
 
3235
            formatBytes(el->bytesMulticastRcvd, 1),
 
3236
            formatPkts(el->pktMulticastRcvd)
 
3237
            ) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3238
    sendString(buf);
 
3239
  }
 
3240
 
 
3241
  if(el->bytesSent == 0)
 
3242
    percentage = 0;
 
3243
  else
 
3244
    percentage = 100 - (((float)el->bytesSentRemotely*100)/el->bytesSent);
 
3245
 
 
3246
  if(el->hostNumIpAddress[0] != '\0') {
 
3247
    printTableEntryPercentage(buf, sizeof(buf), "Data&nbsp;Sent&nbsp;Stats",
 
3248
                              "Local", "Remote", -1, percentage);
 
3249
  }
 
3250
 
 
3251
  if(el->bytesSent > 0) {
 
3252
    percentage = (((float)el->ipBytesSent*100)/el->bytesSent);    
 
3253
    printTableEntryPercentage(buf, sizeof(buf), "IP&nbsp;vs.&nbsp;Non-IP&nbsp;Sent",
 
3254
                              "IP", "Non-IP", -1, percentage);
 
3255
  }
 
3256
 
 
3257
  if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3258
          "%s/%s Pkts/%s Retran. Pkts [%d%%]</TD></TR>\n",
 
3259
          getRowColor(), "Total&nbsp;Data&nbsp;Rcvd",
 
3260
          formatBytes(el->bytesReceived, 1), formatPkts(el->pktReceived),
 
3261
          formatPkts(el->pktDuplicatedAckRcvd),
 
3262
          (int)((float)(el->pktDuplicatedAckRcvd*100)/(float)(el->pktReceived+1))) < 0)
 
3263
    traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3264
  sendString(buf);
 
3265
 
 
3266
  if(el->bytesReceived == 0)
 
3267
    percentage = 0;
 
3268
  else
 
3269
    percentage = 100 - (((float)el->bytesReceivedFromRemote*100)/el->bytesReceived);
 
3270
 
 
3271
  if(el->hostNumIpAddress[0] != '\0')
 
3272
    printTableEntryPercentage(buf, sizeof(buf), "Data&nbsp;Received&nbsp;Stats",
 
3273
                              "Local", "Remote", -1, percentage);
 
3274
  
 
3275
  if(el->bytesReceived > 0) {
 
3276
    percentage = (((float)el->ipBytesReceived*100)/el->bytesReceived);    
 
3277
    printTableEntryPercentage(buf, sizeof(buf), "IP&nbsp;vs.&nbsp;Non-IP&nbsp;Received",
 
3278
                              "IP", "Non-IP", -1, percentage);
 
3279
  }
 
3280
 
 
3281
  total = el->pktSent+el->pktReceived;
 
3282
  if(total > 0) {
 
3283
    percentage = ((float)el->pktSent*100)/((float)total);    
 
3284
    printTableEntryPercentage(buf, sizeof(buf), "Sent&nbsp;vs.&nbsp;Rcvd&nbsp;Pkts",
 
3285
                              "Sent", "Rcvd", -1, percentage);
 
3286
  }
 
3287
 
 
3288
  total = el->bytesSent+el->bytesReceived;
 
3289
  if(total > 0) {
 
3290
    percentage = ((float)el->bytesSent*100)/((float)total);    
 
3291
    printTableEntryPercentage(buf, sizeof(buf), "Sent&nbsp;vs.&nbsp;Rcvd&nbsp;Data",
 
3292
                              "Sent", "Rcvd", -1, percentage);
 
3293
  }
 
3294
  
 
3295
  /* ******************** */
 
3296
 
 
3297
  printedHeader=0;
 
3298
  for(i=0; i<MAX_NUM_CONTACTED_PEERS; i++) {
 
3299
    if(el->contactedRouters.peersIndexes[i] != NO_PEER) {
 
3300
      int routerIdx = el->contactedRouters.peersIndexes[i];
 
3301
      HostTraffic *router = device[actualReportDeviceId].hash_hostTraffic[checkSessionIdx(routerIdx)];
 
3302
 
 
3303
      if(router != NULL) {
 
3304
        if(!printedHeader) {
 
3305
          if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>"
 
3306
                      "Used&nbsp;Subnet&nbsp;Routers</TH><TD "TD_BG"  ALIGN=RIGHT>\n", 
 
3307
                      getRowColor()) < 0)
 
3308
            traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3309
          sendString(buf);
 
3310
        }
 
3311
        printedHeader++;
 
3312
 
 
3313
        if(printedHeader > 1) sendString("<BR>");
 
3314
 
 
3315
        if(snprintf(buf, sizeof(buf), "%s\n", makeHostLink(router, SHORT_FORMAT, 0, 0)) < 0) 
 
3316
          traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3317
        sendString(buf);
 
3318
      }
 
3319
    }
 
3320
  }
 
3321
 
 
3322
  checkHostProvidedServices(el);
 
3323
 
 
3324
  /* **************************** */
 
3325
  /*
 
3326
    Fix courtesy of
 
3327
    Albert Chin-A-Young <china@thewrittenword.com>
 
3328
  */
 
3329
  if(printedHeader > 1)
 
3330
    sendString("</OL></TD></TR>\n");
 
3331
 
 
3332
  if((el->hostNumIpAddress[0] != '\0')
 
3333
     && (!subnetPseudoLocalHost(el))
 
3334
     && (!multicastHost(el))
 
3335
     && (!privateIPAddress(el))
 
3336
     && (mapperURL[0] > 0)) {
 
3337
    if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG" ALIGN=LEFT>%s</TH><TD "TD_BG"  ALIGN=RIGHT>"
 
3338
                "<IMG SRC=\"%s?host=%s\" WIDTH=320 HEIGHT=200></TD></TR>\n",
 
3339
                getRowColor(),
 
3340
                "Host Physical Location",
 
3341
                mapperURL, el->hostNumIpAddress) < 0)
 
3342
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3343
    sendString(buf);
 
3344
  }
 
3345
 
 
3346
  checkHostHealthness(el);
 
3347
 
 
3348
  sendString("</TABLE>"TABLE_OFF"<P>\n");
 
3349
  sendString("</CENTER>\n");
 
3350
}
 
3351
 
 
3352
/* ************************************ */
 
3353
 
 
3354
void printServiceStats(char* svcName, ServiceStats* ss,
 
3355
                       short printSentStats) {
 
3356
  char buf[BUF_SIZE];
 
3357
  TrafficCounter tot, tot1;
 
3358
  float f1, f2, f3, f4;
 
3359
 
 
3360
  if(ss != NULL) {
 
3361
    if(printSentStats) {
 
3362
      tot = ss->numLocalReqSent+ss->numRemoteReqSent;
 
3363
 
 
3364
      if(tot == 0)
 
3365
        f1 = f2 = 0;
 
3366
      else {
 
3367
        f1 = (ss->numLocalReqSent*100)/tot;
 
3368
        f2 = (ss->numRemoteReqSent*100)/tot;
 
3369
      }
 
3370
 
 
3371
      tot1 = ss->numPositiveReplRcvd+ss->numNegativeReplRcvd;
 
3372
      if(tot1 == 0)
 
3373
        f3 = f4 = 0;
 
3374
      else {
 
3375
        f3 = (ss->numPositiveReplRcvd*100)/tot1;
 
3376
        f4 = (ss->numNegativeReplRcvd*100)/tot1;
 
3377
      }
 
3378
 
 
3379
      if((tot > 0) || (tot1 > 0)) {
 
3380
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG">%s</TH>"
 
3381
                "<TD "TD_BG"  ALIGN=CENTER>%s</TD><TD "TD_BG"  ALIGN=CENTER>%.1f%%</TD>"
 
3382
                "<TD "TD_BG"  ALIGN=CENTER>%s</TD><TD "TD_BG"  ALIGN=CENTER>%.1f%%</TD>"
 
3383
                "<TD "TD_BG"  ALIGN=CENTER>%s</TD><TD "TD_BG"  ALIGN=CENTER>%.1f%%</TD>"
 
3384
                "<TD "TD_BG"  ALIGN=CENTER>%s</TD><TD "TD_BG"  ALIGN=CENTER>%.1f%%</TD>"
 
3385
                "<TD "TD_BG"  ALIGN=CENTER>%s - %s</TD><TD "TD_BG"  ALIGN=CENTER>%s - %s</TD>"
 
3386
                "</TR>\n",
 
3387
                getRowColor(), svcName,
 
3388
                formatPkts(ss->numLocalReqSent), f1,
 
3389
                formatPkts(ss->numRemoteReqSent), f2,
 
3390
                formatPkts(ss->numPositiveReplRcvd), f3,
 
3391
                formatPkts(ss->numNegativeReplRcvd), f4,
 
3392
                formatMicroSeconds(ss->fastestMicrosecLocalReqMade),
 
3393
                formatMicroSeconds(ss->slowestMicrosecLocalReqMade),
 
3394
                formatMicroSeconds(ss->fastestMicrosecRemoteReqMade),
 
3395
                formatMicroSeconds(ss->slowestMicrosecRemoteReqMade)
 
3396
                ) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3397
        sendString(buf);
 
3398
      }
 
3399
    } else {
 
3400
      tot = ss->numLocalReqRcvd+ss->numRemoteReqRcvd;
 
3401
 
 
3402
      if(tot == 0)
 
3403
        f1 = f2 = 0;
 
3404
      else {
 
3405
        f1 = (ss->numLocalReqRcvd*100)/tot;
 
3406
        f2 = (ss->numRemoteReqRcvd*100)/tot;
 
3407
      }
 
3408
 
 
3409
      tot1 = ss->numPositiveReplSent+ss->numNegativeReplSent;
 
3410
      if(tot1 == 0)
 
3411
        f3 = f4 = 0;
 
3412
      else {
 
3413
        f3 = (ss->numPositiveReplSent*100)/tot1;
 
3414
        f4 = (ss->numNegativeReplSent*100)/tot1;
 
3415
      }
 
3416
 
 
3417
      if((tot > 0) || (tot1 > 0)) {
 
3418
        if(snprintf(buf, sizeof(buf), "<TR %s><TH "TH_BG">%s</TH>"
 
3419
                "<TD "TD_BG"  ALIGN=CENTER>%s</TD><TD "TD_BG"  ALIGN=CENTER>%.1f%%</TD>"
 
3420
                "<TD "TD_BG"  ALIGN=CENTER>%s</TD><TD "TD_BG"  ALIGN=CENTER>%.1f%%</TD>"
 
3421
                "<TD "TD_BG"  ALIGN=CENTER>%s</TD><TD "TD_BG"  ALIGN=CENTER>%.1f%%</TD>"
 
3422
                "<TD "TD_BG"  ALIGN=CENTER>%s</TD><TD "TD_BG"  ALIGN=CENTER>%.1f%%</TD>"
 
3423
                "<TD "TD_BG"  ALIGN=CENTER>%s - %s</TD><TD "TD_BG"  ALIGN=CENTER>%s - %s</TD>"
 
3424
                "</TR>\n",
 
3425
                getRowColor(), svcName,
 
3426
                formatPkts(ss->numLocalReqRcvd), f1,
 
3427
                formatPkts(ss->numRemoteReqRcvd), f2,
 
3428
                formatPkts(ss->numPositiveReplSent), f3,
 
3429
                formatPkts(ss->numNegativeReplSent), f4,
 
3430
                formatMicroSeconds(ss->fastestMicrosecLocalReqServed),
 
3431
                formatMicroSeconds(ss->slowestMicrosecLocalReqServed),
 
3432
                formatMicroSeconds(ss->fastestMicrosecRemoteReqServed),
 
3433
                formatMicroSeconds(ss->slowestMicrosecRemoteReqServed)
 
3434
                ) < 0) traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3435
        sendString(buf);
 
3436
      }
 
3437
    }
 
3438
  }
 
3439
}
 
3440
 
 
3441
/* ************************************ */
 
3442
 
 
3443
#ifdef ENABLE_NAPSTER
 
3444
static void printNapsterStats(HostTraffic *el) {
 
3445
 
 
3446
  printSectionTitle("Napster Stats");
 
3447
 
 
3448
  sendString("<CENTER>"TABLE_ON"<TABLE BORDER=1>\n");
 
3449
  sendString("<TR><TH "TH_BG" ALIGN=LEFT># Connections Requested</TH><TD ALIGN=RIGHT>");
 
3450
  sendString(formatPkts(el->napsterStats->numConnectionsRequested));
 
3451
  sendString("</TD></TR>\n");
 
3452
  sendString("<TR><TH "TH_BG" ALIGN=LEFT># Connections Served</TH><TD ALIGN=RIGHT>");
 
3453
  sendString(formatPkts(el->napsterStats->numConnectionsServed));
 
3454
  sendString("</TD></TR>\n");
 
3455
  sendString("<TR><TH "TH_BG" ALIGN=LEFT># Search Requested</TH><TD ALIGN=RIGHT>");
 
3456
  sendString(formatPkts(el->napsterStats->numSearchSent));
 
3457
  sendString("</TD></TR>\n");
 
3458
  sendString("<TR><TH "TH_BG" ALIGN=LEFT># Search Served</TH><TD ALIGN=RIGHT>");
 
3459
  sendString(formatPkts(el->napsterStats->numSearchRcvd));
 
3460
  sendString("</TD></TR>\n");
 
3461
  sendString("<TR><TH "TH_BG" ALIGN=LEFT># Downloads Requested</TH><TD ALIGN=RIGHT>");
 
3462
  sendString(formatPkts(el->napsterStats->numDownloadsRequested));
 
3463
  sendString("</TD></TR>\n");
 
3464
  sendString("<TR><TH "TH_BG" ALIGN=LEFT># Downloads Served</TH><TD ALIGN=RIGHT>");
 
3465
  sendString(formatPkts(el->napsterStats->numDownloadsServed));
 
3466
  sendString("</TD></TR>\n");
 
3467
  sendString("<TR><TH "TH_BG" ALIGN=LEFT>Data Sent</TH><TD ALIGN=RIGHT>");
 
3468
  sendString(formatBytes(el->napsterStats->bytesSent, 1));
 
3469
  sendString("</TD></TR>\n");
 
3470
  sendString("<TR><TH "TH_BG" ALIGN=LEFT>Data Received</TH><TD ALIGN=RIGHT>");
 
3471
  sendString(formatBytes(el->napsterStats->bytesRcvd, 1));
 
3472
  sendString("</TD></TR>\n");
 
3473
 
 
3474
  sendString("</TABLE>"TABLE_OFF"</CENTER>\n");
 
3475
}
 
3476
#endif
 
3477
 
 
3478
/* ************************************ */
 
3479
 
 
3480
void printHostUsedServices(HostTraffic *el) {
 
3481
  TrafficCounter tot;
 
3482
 
 
3483
#ifdef ENABLE_NAPSTER
 
3484
  if(el->napsterStats != NULL)
 
3485
    printNapsterStats(el);
 
3486
#endif
 
3487
 
 
3488
  if((el->dnsStats == NULL) && (el->httpStats == NULL))
 
3489
    return;
 
3490
 
 
3491
  tot = 0;
 
3492
 
 
3493
  if(el->dnsStats)
 
3494
    tot += el->dnsStats->numLocalReqSent+el->dnsStats->numRemoteReqSent;
 
3495
 
 
3496
  if(el->httpStats)
 
3497
    tot += el->httpStats->numLocalReqSent+el->httpStats->numRemoteReqSent;
 
3498
 
 
3499
  if(tot > 0) {
 
3500
    printSectionTitle("IP&nbsp;Service&nbsp;Stats:&nbsp;Client&nbsp;Role");
 
3501
    sendString("<CENTER>\n");
 
3502
    sendString(""TABLE_ON"<TABLE BORDER=1 WIDTH=100%%>\n<TR>"
 
3503
               "<TH "TH_BG">&nbsp;</TH>"
 
3504
               "<TH "TH_BG" COLSPAN=2>#&nbsp;Loc.&nbsp;Req.&nbsp;Sent</TH>"
 
3505
               "<TH "TH_BG" COLSPAN=2>#&nbsp;Rem.&nbsp;Req.&nbsp;Sent</TH>"
 
3506
               "<TH "TH_BG" COLSPAN=2>#&nbsp;Pos.&nbsp;Reply&nbsp;Rcvd</TH>"
 
3507
               "<TH "TH_BG" COLSPAN=2>#&nbsp;Neg.&nbsp;Reply&nbsp;Rcvd</TH>"
 
3508
               "<TH "TH_BG">Local&nbsp;RndTrip</TH>"
 
3509
               "<TH "TH_BG">Remote&nbsp;RndTrip</TH>"
 
3510
               "</TR>\n");
 
3511
 
 
3512
    if(el->dnsStats) printServiceStats("DNS", el->dnsStats, 1);
 
3513
    if(el->httpStats) printServiceStats("HTTP", el->httpStats, 1);
 
3514
 
 
3515
    sendString("</TABLE>"TABLE_OFF"\n");
 
3516
    sendString("</CENTER>\n");
 
3517
  }
 
3518
 
 
3519
  /* ************ */
 
3520
 
 
3521
  tot = 0;
 
3522
 
 
3523
  if(el->dnsStats)
 
3524
    tot += el->dnsStats->numLocalReqRcvd+el->dnsStats->numRemoteReqRcvd;
 
3525
 
 
3526
  if(el->httpStats)
 
3527
    tot += el->httpStats->numLocalReqRcvd+el->httpStats->numRemoteReqRcvd;
 
3528
 
 
3529
  if(tot > 0) {
 
3530
    printSectionTitle("IP&nbsp;Service&nbsp;Stats:&nbsp;Server&nbsp;Role");
 
3531
    sendString("<CENTER>\n");
 
3532
    sendString("<P>"TABLE_ON"<TABLE BORDER=1 WIDTH=100%%>\n<TR>"
 
3533
               "<TH "TH_BG">&nbsp;</TH>"
 
3534
               "<TH "TH_BG" COLSPAN=2>#&nbsp;Loc.&nbsp;Req.&nbsp;Rcvd</TH>"
 
3535
               "<TH "TH_BG" COLSPAN=2>#&nbsp;Rem.&nbsp;Req.&nbsp;Rcvd</TH>"
 
3536
               "<TH "TH_BG" COLSPAN=2>#&nbsp;Pos.&nbsp;Reply&nbsp;Sent</TH>"
 
3537
               "<TH "TH_BG" COLSPAN=2>#&nbsp;Neg.&nbsp;Reply&nbsp;Sent</TH>"
 
3538
               "<TH "TH_BG">Local&nbsp;RndTrip</TH>"
 
3539
               "<TH "TH_BG">Remote&nbsp;RndTrip</TH>"
 
3540
               "</TR>\n");
 
3541
 
 
3542
    if(el->dnsStats) printServiceStats("DNS", el->dnsStats, 0);
 
3543
    if(el->httpStats) printServiceStats("HTTP", el->httpStats, 0);
 
3544
 
 
3545
    sendString("</TABLE>"TABLE_OFF"\n");
 
3546
    sendString("</CENTER>\n");
 
3547
  }
 
3548
}
 
3549
 
 
3550
/* ********************************** */
 
3551
 
 
3552
void printTableEntry(char *buf, int bufLen,
 
3553
                     char *label, char* color,
 
3554
                     float total, float percentage) {
 
3555
  int int_perc;
 
3556
 
 
3557
  if(total == 0) return;
 
3558
 
 
3559
  int_perc = (int)percentage;
 
3560
 
 
3561
  /* This shouldn't happen */
 
3562
  if(int_perc < 0) {
 
3563
    int_perc = 0;
 
3564
    percentage = 0;
 
3565
  } else if(int_perc > 100) {
 
3566
    int_perc = 100;
 
3567
    percentage = 100;
 
3568
  }
 
3569
 
 
3570
  switch(int_perc) {
 
3571
  case 0:
 
3572
    if(snprintf(buf, bufLen, "<TR %s><TH "TH_BG" ALIGN=LEFT WIDTH=150>%s</TH>"
 
3573
                "<TD "TD_BG"  ALIGN=RIGHT WIDTH=100>%s</TD>"
 
3574
                "<TD "TD_BG" WIDTH=250>&nbsp;</TD></TR>\n",
 
3575
                getRowColor(), label, formatKBytes(total)) < 0)
 
3576
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3577
    break;
 
3578
  case 100:
 
3579
    if(snprintf(buf, bufLen, "<TR %s><TH "TH_BG" ALIGN=LEFT WIDTH=150>%s</TH>"
 
3580
                "<TD "TD_BG"  ALIGN=RIGHT WIDTH=100>%s</TD>"
 
3581
                "<TD ALIGN=CENTER WIDTH=250><IMG ALT=\"100%%\" ALIGN=MIDDLE SRC=/gauge.jpg WIDTH=\"250\" HEIGHT=12>"
 
3582
                "</TD></TR>\n",
 
3583
                getRowColor(), label, formatKBytes(total)) < 0)
 
3584
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3585
    break;
 
3586
  default:
 
3587
    if(snprintf(buf, bufLen, "<TR %s><TH "TH_BG" ALIGN=LEFT WIDTH=150>%s</TH>"
 
3588
                "<TD "TD_BG" ALIGN=RIGHT WIDTH=100>%s</TD>"
 
3589
                "<TD "TD_BG" WIDTH=250><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"250\">"
 
3590
                "<TR><TD><IMG ALIGN=MIDDLE ALT=\"%d%%\" SRC=/gauge.jpg WIDTH=\"%d\" HEIGHT=12>"
 
3591
                "</TD><TD "TD_BG" ALIGN=CENTER WIDTH=\"%d\" %s>"
 
3592
                "<P>&nbsp;</TD></TR></TABLE></TD></TR>\n",
 
3593
                getRowColor(), label, formatKBytes(total),
 
3594
                int_perc, (250*int_perc)/100, 
 
3595
                (250*(100-int_perc))/100, getActualRowColor()) < 0)
 
3596
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3597
  }
 
3598
 
 
3599
  sendString(buf);
 
3600
}
 
3601
 
 
3602
/* ************************ */
 
3603
 
 
3604
char* buildHTMLBrowserWindowsLabel(int i, int j) {
 
3605
  static char buf[BUF_SIZE];
 
3606
  int idx = i*device[actualReportDeviceId].numHosts + j;
 
3607
 
 
3608
#ifdef MULTITHREADED
 
3609
  accessMutex(&addressResolutionMutex, "buildHTMLBrowserWindowsLabel");
 
3610
#endif
 
3611
 
 
3612
  if((device[actualReportDeviceId].ipTrafficMatrix[idx] == NULL)
 
3613
     || ((device[actualReportDeviceId].ipTrafficMatrix[idx]->bytesSent == 0)
 
3614
         && (device[actualReportDeviceId].ipTrafficMatrix[idx]->bytesReceived == 0)))
 
3615
    buf[0]='\0';
 
3616
  else if ((device[actualReportDeviceId].ipTrafficMatrix[idx]->bytesSent > 0)
 
3617
           && (device[actualReportDeviceId].ipTrafficMatrix[idx]->bytesReceived == 0)) {
 
3618
    if(snprintf(buf, sizeof(buf), "(%s->%s)=%s",
 
3619
                device[actualReportDeviceId].ipTrafficMatrixHosts[i]->hostSymIpAddress,
 
3620
                device[actualReportDeviceId].ipTrafficMatrixHosts[j]->hostSymIpAddress,
 
3621
                formatBytes(device[actualReportDeviceId].ipTrafficMatrix[idx]->bytesSent, 1)) < 0)
 
3622
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3623
  } else if ((device[actualReportDeviceId].ipTrafficMatrix[idx]->bytesSent == 0)
 
3624
             && (device[actualReportDeviceId].ipTrafficMatrix[idx]->bytesReceived > 0)) {
 
3625
    if(snprintf(buf, sizeof(buf), "(%s->%s)=%s",
 
3626
                device[actualReportDeviceId].ipTrafficMatrixHosts[j]->hostSymIpAddress,
 
3627
                device[actualReportDeviceId].ipTrafficMatrixHosts[i]->hostSymIpAddress,
 
3628
                formatBytes(device[actualReportDeviceId].ipTrafficMatrix[idx]->bytesReceived, 1)) < 0)
 
3629
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3630
  } else {
 
3631
    if(snprintf(buf, sizeof(buf), "(%s->%s)=%s, (%s->%s)=%s",
 
3632
                device[actualReportDeviceId].ipTrafficMatrixHosts[i]->hostSymIpAddress,
 
3633
                device[actualReportDeviceId].ipTrafficMatrixHosts[j]->hostSymIpAddress,
 
3634
                formatBytes(device[actualReportDeviceId].ipTrafficMatrix[idx]->bytesSent, 1),
 
3635
                device[actualReportDeviceId].ipTrafficMatrixHosts[j]->hostSymIpAddress,
 
3636
                device[actualReportDeviceId].ipTrafficMatrixHosts[i]->hostSymIpAddress,
 
3637
                formatBytes(device[actualReportDeviceId].ipTrafficMatrix[idx]->bytesReceived, 1)) < 0)
 
3638
      traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3639
  }
 
3640
 
 
3641
#ifdef MULTITHREADED
 
3642
  releaseMutex(&addressResolutionMutex);
 
3643
#endif
 
3644
 
 
3645
  return(buf);
 
3646
}
 
3647
 
 
3648
/* ************************ */
 
3649
 
 
3650
int cmpEventsFctn(const void *_a, const void *_b) {
 
3651
  EventMsg **a = (EventMsg**)_a;
 
3652
  EventMsg **b = (EventMsg**)_b;
 
3653
 
 
3654
  switch(columnSort) {
 
3655
  case 0: /* Event Time */
 
3656
    if((*a)->eventTime > (*b)->eventTime)
 
3657
      return(-1);
 
3658
    else if((*a)->eventTime < (*b)->eventTime)
 
3659
      return(1);
 
3660
    else
 
3661
      return(0);
 
3662
    break;
 
3663
  case 1: /* Severity */
 
3664
    if((*a)->severity > (*b)->severity)
 
3665
      return(-1);
 
3666
    else if((*a)->severity < (*b)->severity)
 
3667
      return(1);
 
3668
    else
 
3669
      return(0);
 
3670
    break;
 
3671
  case 2: /* Rule Id */
 
3672
    if((*a)->ruleId > (*b)->ruleId)
 
3673
      return(-1);
 
3674
    else if((*a)->ruleId < (*b)->ruleId)
 
3675
      return(1);
 
3676
    else
 
3677
      return(0);
 
3678
    break;
 
3679
  }
 
3680
 
 
3681
  return(0);
 
3682
}
 
3683
 
 
3684
/* *********************************** */
 
3685
 
 
3686
void printHostHourlyTrafficEntry(HostTraffic *el, int i,
 
3687
                            TrafficCounter tcSent,
 
3688
                            TrafficCounter tcRcvd) {
 
3689
  float pctg;
 
3690
  char buf[BUF_SIZE];
 
3691
 
 
3692
  if(snprintf(buf, BUF_SIZE, "<TD "TD_BG"  ALIGN=RIGHT>%s</TD>",
 
3693
           formatBytes(el->last24HoursBytesSent[i], 0)) < 0)
 
3694
    traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3695
  sendString(buf);
 
3696
  if(tcSent > 0)
 
3697
    pctg = (float)(el->last24HoursBytesSent[i]*100)/(float)tcSent;
 
3698
  else
 
3699
    pctg = 0;
 
3700
  if(snprintf(buf, BUF_SIZE, "<TD ALIGN=RIGHT %s>%.1f %%</TD>",
 
3701
           getBgPctgColor(pctg), pctg) < 0)
 
3702
    traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3703
  sendString(buf);
 
3704
  if(snprintf(buf, BUF_SIZE, "<TD "TD_BG"  ALIGN=RIGHT>%s</TD>",
 
3705
           formatBytes(el->last24HoursBytesRcvd[i], 0)) < 0)
 
3706
    traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3707
  sendString(buf);
 
3708
  if(tcRcvd > 0)
 
3709
    pctg = (float)(el->last24HoursBytesRcvd[i]*100)/(float)tcRcvd;
 
3710
  else
 
3711
    pctg = 0;
 
3712
 
 
3713
  if(snprintf(buf, BUF_SIZE, "<TD ALIGN=RIGHT %s>%.1f %%</TD></TR>",
 
3714
           getBgPctgColor(pctg), pctg) < 0)
 
3715
    traceEvent(TRACE_ERROR, "Buffer overflow!");
 
3716
  sendString(buf);
 
3717
}
 
3718
 
 
3719
/* ************************************ */
 
3720
 
 
3721
char* getNbNodeType(char nodeType) {
 
3722
 
 
3723
  switch(nodeType) {
 
3724
  case 0x0:
 
3725
    return("Workstation");
 
3726
  case 0x20:
 
3727
  default:
 
3728
    return("Server");
 
3729
  }
 
3730
 
 
3731
  return(""); /* NOTREACHED */
 
3732
}
 
3733
 
 
3734
#endif /* MICRO_NTOP */
 
3735
 
 
3736
 /* ********************************** */
 
3737
 
 
3738
void printFlagedWarning(char *text) {
 
3739
  char buf[BUF_SIZE];
 
3740
 
 
3741
  snprintf(buf, BUF_SIZE,
 
3742
           "<CENTER>\n"
 
3743
           "<P><IMG ALT=Warning SRC=/warning.gif>\n"
 
3744
           "<P><FONT COLOR=\"#FF0000\" SIZE=+1>%s</FONT>\n"
 
3745
           "</CENTER>\n", text);
 
3746
  sendString(buf);
 
3747
}
 
3748
 
 
3749
/* ********************************** */
 
3750
 
 
3751
void printSectionTitle(char *text) {
 
3752
  char buf[BUF_SIZE];
 
3753
 
 
3754
  snprintf(buf, BUF_SIZE,
 
3755
           "<CENTER>\n"
 
3756
           "<H1><FONT FACE=\"Helvetica, Arial, Sans Serif\">%s</FONT></H1><P>\n"
 
3757
           "</CENTER>\n", text);
 
3758
  sendString(buf);
 
3759
}
 
3760
 
 
3761