Re: [tcpdump-workers] print_llc code question

2009-09-07 Thread Jean-Louis Charton
Guy Harris  alum.mit.edu> writes:

> 
> So I don't know who actually *used* an 802.2 header without a SNAP  
> header when sending IP datagrams.
>

I agree that IP + LLC without SNAP is probably very unusual.

Michael Richardson suggested me that the extra byte could be there to make the
IP datagram 32 bit aligned ...

J-L

-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


[tcpdump-workers] Help with script using pcap.h

2009-09-07 Thread J.R. Sellers
Hello everyone!  First off - I am beginner at this kind of stuff so please
bare with me on this.  I am a firefighter at a fire station.  We currently
have a program that runs "cygwin" on Windows and runs the following script.
 I am trying to move this script over to a Ubuntu Server that runs faster
and more efficiently than the computer that is running Windows 2000.
The goal of this program is to capture a printout that is sent from the
dispatchers to a printer at our station.  The program then reads the
printout line by line and determines if it needs to send the call to the
signboard displays and play a message.  This program is hopefully able to
run continuously with no down time.

I finally have figured out how to compile the script and make it run,
however I get a segment fragmentation error when it runs.  I have also been
told by someone who is smart in this kind of stuff that the reason the
program currently crashes so much in Windows is because it is not "releasing
memory" back to the system and is getting larger and larger until the
computer runs out of memory.   A copy of the script is attached.  Any help
in improving the script would be greatly appreciated!

Thanks again!  J.R. Sellers

prealert.c File:
---

#include 
#include 
#include 

void packet_handler(u_char *param, const struct pcap_pkthdr *header, const
u_char *pkt_data);
void checklinesforaction(char *, char *, int, int *, int *, int *, int *);
void checkbackups(char *, char *, int *, int *, int *, int *);
void dispatchunits(char *, char *, char *, int *, int *, int *, int *);

void checklinesforaction(char *linetocheck, char *checkforcommand, int
setto, int *a, int *e, int *eb, int *t)
{

char * search;

search = 0;
search = strstr(linetocheck, checkforcommand);
if(search)
{
search = 0;
search = strstr(linetocheck, "A834");
if(search)
*a = setto;

search = 0;
search = strstr(linetocheck, "E834");
if(search)
*e = setto;
search = 0;
search = strstr(linetocheck, "E834B");
if(search)
*eb = setto;

search = 0;
search = strstr(linetocheck, "TK834");
if(search)
*t = setto;
}
}


void checkbackups(char *linetocheck, char *back, int *a, int *e, int *eb,
int *t)
{

char * search;
char * search2;
char first[16];
char hold[16];

search = 0;
search = strstr(linetocheck, back);
if(search)
{
search2 = 0;
search2 = strstr(search, "A834");
if(search2)
*a = 1;
search2 = 0;
search2 = strstr(search, "E834");
if(search2)
*e = 1;
search2 = 0;
search2 = strstr(search, "E834B");
if(search2)
*eb = 1;
search2 = 0;
search2 = strstr(search, "TK834");
if(search2)
*t = 1;
sscanf(search, "%s %s", hold, first);
if(strcmp("A834", first) == 0)
*a = 0;
if(strcmp("E834", first) == 0)
*e = 0;
if(strcmp("E834B", first) == 0)
*eb = 0;
if(strcmp("TK834", first) == 0)
*t = 0;
}
}

void dispatchunits(char *area, char *type, char *location, int *ap, int *ep,
int *ebp, int *tp)
{

int a = *ap;
int e = *ep;
int eb = *ebp;
int t = *tp;

int beforeflag = 0;
char betastring[256];
char talstring[256];
char soundstring[256];
sprintf(talstring, ":%s:%s   %s\"", type, area, location);
sprintf(soundstring, "soundtest ");

if((a==1) && (e!=1) && (eb!=1) && (t!=1))
{
sprintf(betastring, "beta g r \"AMB:%s:%s   %s\"", type, area, location);
system(betastring);
system("soundtest ambulance.wav");
printf("Dispatching AMBO:\n%s\n", betastring);
} else if( !(strcmp(type, "HOUSEF")) || !(strcmp(type, "BUILDF")) ||
!(strcmp(type, "APTF"))
|| !(strcmp(type, "2ALRM")) )
{
if( ((e==1) || (eb==1) || (t==1)) && !(strcmp(area, "34")) )
{
sprintf(betastring, "beta r r \"DUMP THE HOUSE!   %s\"", location);
system(betastring);
system("soundtest house.wav");
printf("Dispatching FIRST DUE FIRE:\n%s\n", betastring);
} else if( ((e==1) || (eb==1) || (t==1)) )
{
strcat(soundstring, "fire");
sprintf(betastring, "beta r r \"");
if(t==1)
{
strcat(betastring, "TRK");
strcat(soundstring, "trk");
beforeflag = 1;
}
if(e==1)
{
if(beforeflag)
strcat(betastring, ":");
strcat(betastring, "ENG");
strcat(soundstring, "eng");
beforeflag = 1;
}
if(eb==1)
{
if(beforeflag)
strcat(betastring, ":");
strcat(betastring, "ENGB");
strcat(soundstring, "eng");
}
strcat(betastring, talstring);
strcat(soundstring, ".wav");
system(betastring);
system(soundstring);
printf("Dispatching FIRE:\n%s\n", betastring);
printf("%s\n", soundstring);
}
} else if(a==1 || e==1 || eb==1 || t==1)
{
sprintf(betastring, "beta y r \"");
if(t==1)
{
strcat(betastring, "TRK");
strcat(soundstring, "trk");
beforeflag = 1;
}
if(e==1)
{
if(beforeflag)
strcat(betastring, ":");
strcat(betastring, "ENG");
strcat(soundstring, "eng");
beforeflag = 1;
}
if(eb==1)
{
if(beforeflag)
strcat(betastring, ":");
strcat(betastring, "ENGB");
strcat(soundstring, "eng");
beforeflag = 1;
}
if(a==1)
{
if(beforeflag)
strcat(betastring, ":");
strcat(betastring, "AMB");
strcat(soundstring, "amb");
beforeflag = 1;
}
strcat(betastring, talstr

Re: [PATCH] Re: [tcpdump-workers] Bug: Counting dropped packets in

2009-09-07 Thread Guy Harris


On Aug 31, 2009, at 2:36 PM, Dustin Spicuzza wrote:

So... I've changed my patch to populate ps_ifdrop instead, and it  
should

be good to go, without screwing with current applications.


Checked in.


I suppose the
man page should be updated to mention that ps_ifdrop is only supported
on a few platforms (I noticed that grep shows one or two instances  
where

it is used).


The pcap_stats man page should be updated to give more detail in  
general, including that.  I've done that as well.


I also fixed some places where pcap_stats() was leaving ps_ifdrop  
unset, and changed tcpdump to report ps_ifdrop if it's non-zero (and  
to set it to zero before calling pcap_stats(), to handle the platforms  
where it was being left unset).

-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.