From f4d3f0dc920f69aa903f91ae0ef2fb14b9a5195b Mon Sep 17 00:00:00 2001 From: Thomas Osterried Date: Sat, 10 Dec 2005 14:45:02 +0000 Subject: - Increased max value for mheard list to 1000. New default is 100. - New option "-p port1[,port2,..] for including / excluding ports. Todo: different lists and sizes for earch port Requests were by f4ecw. --- ax25/mheardd.8 | 12 +++++++++--- ax25/mheardd.c | 44 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 8 deletions(-) (limited to 'ax25') diff --git a/ax25/mheardd.8 b/ax25/mheardd.8 index 63cda36..c0dd200 100644 --- a/ax25/mheardd.8 +++ b/ax25/mheardd.8 @@ -2,7 +2,7 @@ .SH NAME mheardd \- collect information about packet activity .SH SYNOPSIS -.B mheardd [-f] [-l] [-n number] [-v] +.B mheardd [-f] [-l] [-n number] [-p [!]port1[,port2,..]] [-v] .SH DESCRIPTION .LP .B Mheardd @@ -25,8 +25,14 @@ default. Enables logging to the system log file. The default is off. .TP 10 .BI "\-n number" -Sets the number of entries in the activity list file, the default is 40. The -minimum value allowed is 10 and the maximum is 100. +Sets the number of entries in the activity list file, the default is 100. The +minimum value allowed is 10 and the maximum is 1000. +.TP 10 +.BI "\-p [!]port1[,port2,..]" +With -p, you instruct mheardd to only listen on specified ax25 ports. +You may give more ports, seperated by ','. +If you introduce the port(s) by a leading '!', then mheardd will listen +on all ports except those you specified. .TP 10 .BI \-v Display the version. diff --git a/ax25/mheardd.c b/ax25/mheardd.c index d0aab98..3de25ea 100644 --- a/ax25/mheardd.c +++ b/ax25/mheardd.c @@ -93,7 +93,8 @@ struct mheard_list_struct { }; static struct mheard_list_struct *mheard_list; -static int mheard_list_size = 40; +#define MHEARD_LIST_SIZE 1000 +static int mheard_list_size = MHEARD_LIST_SIZE/10; static int logging = FALSE; static int ftype(unsigned char *, int *, int); @@ -120,8 +121,12 @@ int main(int argc, char **argv) long position; int ctlen, type, end, extseq, flush = FALSE; FILE *fp; + char *p; + char ports[1024]; + int ports_excl = 0; - while ((s = getopt(argc, argv, "fln:v")) != -1) { + *ports = 0; + while ((s = getopt(argc, argv, "fln:p:v")) != -1) { switch (s) { case 'l': logging = TRUE; @@ -131,11 +136,26 @@ int main(int argc, char **argv) break; case 'n': mheard_list_size = atoi(optarg); - if (mheard_list_size < 10 || mheard_list_size > 100) { - fprintf(stderr, "mheardd: list size must be between 10 and 100\n"); + if (mheard_list_size < 10 || mheard_list_size > MHEARD_LIST_SIZE) { + fprintf(stderr, "mheardd: list size must be between 10 and %d\n", MHEARD_LIST_SIZE); return 1; } break; + case 'p': + if (strlen(optarg) > sizeof(ports)-4) { + fprintf(stderr, "mheardd: too many ports specified."); + return 1; + } + if (*optarg == '!') { + ports_excl = 1; + optarg++; + } + sprintf(ports, "|%s|", optarg); + for (p = ports; *p; p++) { + if (*p == ' ' || *p == ',') + *p = '|'; + } + break; case 'v': printf("mheardd: %s\n", VERSION); return 0; @@ -143,7 +163,7 @@ int main(int argc, char **argv) fprintf(stderr, "mheardd: option -n needs an argument\n"); return 1; case '?': - fprintf(stderr, "Usage: mheardd [-f] [-l] [-n number] [-v]\n"); + fprintf(stderr, "Usage: mheardd [-f] [-l] [-n number] [-p [!]port1[,port2,..]] [-v]\n"); return 1; } } @@ -214,6 +234,19 @@ int main(int argc, char **argv) syslog(LOG_WARNING, "unknown port '%s'\n", sa.sa_data); continue; } + if (*ports) { + char testport[sizeof(sa.sa_data)+2]; + sprintf(testport, "|%s|", sa.sa_data); + if (ports_excl) { + if (strstr(ports, testport)) { + continue; + } + } else { + if (!strstr(ports, testport)) { + continue; + } + } + } data = buffer; @@ -450,3 +483,4 @@ static struct mheard_list_struct *findentry(ax25_address *callsign, char *port) return oldest; } + -- cgit v1.2.3