summaryrefslogtreecommitdiffstats
path: root/ax25
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2015-05-02 00:19:09 +0200
committerRalf Baechle <ralf@linux-mips.org>2015-05-02 00:19:09 +0200
commit56e847dae8f585254c6b336ea557bd75a0574711 (patch)
tree7e775ea62e06caa505e7ad017e17bbc0800d8ab3 /ax25
parent62ceba5818d888041adbd466e8c67a8104bcf4fa (diff)
parent67d85b3d5cf145a5bf0a1431d6052473b017daa9 (diff)
Merge branch 'master' of git://git.linux-ax25.org/pub/scm/ralf/ax25-tools
Conflicts: ax25/axspawn.c
Diffstat (limited to 'ax25')
-rw-r--r--ax25/Makefile.am8
-rw-r--r--ax25/access.c78
-rw-r--r--ax25/access.h9
-rw-r--r--ax25/ax25.42
-rw-r--r--ax25/ax25d.c806
-rw-r--r--ax25/axctl.c11
-rw-r--r--ax25/axgetput/Makefile.am11
-rw-r--r--ax25/axgetput/axgetput.c555
-rw-r--r--ax25/axgetput/proto_bin.c842
-rw-r--r--ax25/axgetput/util.c71
-rw-r--r--ax25/axparms.88
-rw-r--r--ax25/axparms.c48
-rw-r--r--ax25/axspawn.86
-rw-r--r--ax25/axspawn.c946
-rw-r--r--ax25/beacon.c66
-rw-r--r--ax25/bpqparms.c98
-rw-r--r--ax25/md5.c274
-rw-r--r--ax25/md5.h8
-rw-r--r--ax25/mheard.c268
-rw-r--r--ax25/mheardd.82
-rw-r--r--ax25/mheardd.c249
-rw-r--r--ax25/rxecho.c54
22 files changed, 2206 insertions, 2214 deletions
diff --git a/ax25/Makefile.am b/ax25/Makefile.am
index f5c0ebb..327510e 100644
--- a/ax25/Makefile.am
+++ b/ax25/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = axgetput
+SUBDIRS = axgetput
etcfiles = ax25.profile ax25d.conf axspawn.conf rxecho.conf
varfiles = mheard.dat
@@ -24,18 +24,18 @@ LDADD = $(AX25_LIB)
axspawn_LDADD = $(AX25_LIB) $(UTIL_LIB)
INCLUDES = -DAX25_SYSCONFDIR=\""$(AX25_SYSCONFDIR)"\" \
- -DAX25_LOCALSTATEDIR=\""$(AX25_LOCALSTATEDIR)"\"
+ -DAX25_LOCALSTATEDIR=\""$(AX25_LOCALSTATEDIR)"\"
AX25_SYSCONFDIR=$(sysconfdir)/ax25/
AX25_LOCALSTATEDIR=$(localstatedir)/ax25/
-man_MANS = ax25.4 ax25d.conf.5 axspawn.conf.5 rxecho.conf.5 \
+dist_man_MANS = ax25.4 ax25d.conf.5 axspawn.conf.5 rxecho.conf.5 \
ax25d.8 axctl.8 axparms.8 axspawn.8 beacon.8 bpqparms.8 \
mheard.1 mheardd.8 rxecho.8
-EXTRA_DIST = $(man_MANS) $(etcfiles) $(varfiles)
+EXTRA_DIST = $(etcfiles) $(varfiles)
ax25d_SOURCES = ax25d.c
axctl_SOURCES = axctl.c
diff --git a/ax25/access.c b/ax25/access.c
index bf02b04..5a588db 100644
--- a/ax25/access.c
+++ b/ax25/access.c
@@ -32,7 +32,7 @@ static void char_to_hex(char *c, char *h, int n);
int conv_rand(void)
{
seed = (1103515245L * seed + 12345) & CONV_RAND_MAX;
- return ((int) (seed & 077777));
+ return (int) (seed & 077777);
}
/*--------------------------------------------------------------------------*/
@@ -46,7 +46,7 @@ void conv_randomize(void)
int conv_random(int num, int base)
{
- return (((long) (conv_rand() * time(0)) & CONV_RAND_MAX) % num + base);
+ return ((long) (conv_rand() * time(0)) & CONV_RAND_MAX) % num + base;
}
/*--------------------------------------------------------------------------*/
@@ -82,23 +82,23 @@ char *generate_rand_pw(int len)
if (len > PASSSIZE)
len = PASSSIZE;
- for (i = 0; i < len; i++) {
- j = conv_random(10+26*2, 0);
- if (j < 10) {
- pass[i] = j + '0';
- continue;
- }
- j -= 10;
- if (j < 26) {
- pass[i] = j + 'A';
+ for (i = 0; i < len; i++) {
+ j = conv_random(10+26*2, 0);
+ if (j < 10) {
+ pass[i] = j + '0';
continue;
- }
- j -= 26;
- pass[i] = j + 'a';
- }
- pass[len] = 0;
+ }
+ j -= 10;
+ if (j < 26) {
+ pass[i] = j + 'A';
+ continue;
+ }
+ j -= 26;
+ pass[i] = j + 'a';
+ }
+ pass[len] = 0;
- return pass;
+ return pass;
}
/*--------------------------------------------------------------------------*/
@@ -178,28 +178,28 @@ void ask_pw_md5(char *prompt, char *pass_want, char *pw)
void calc_md5_pw (const char *MD5prompt, const char *MD5pw, char *MD5result)
{
- MD5_CTX context;
- short i, n, len;
- char buffer[1024];
+ MD5_CTX context;
+ short i, n, len;
+ char buffer[1024];
- strncpy(buffer, MD5prompt, 10);
- buffer[10] = 0;
- strcat(buffer, MD5pw);
+ strncpy(buffer, MD5prompt, 10);
+ buffer[10] = 0;
+ strcat(buffer, MD5pw);
- MD5Init(&context);
+ MD5Init(&context);
- len = strlen(buffer);
- for (i= 0; i < len; i += 16) {
- n = (len - i) > 16 ? 16 : (len - i);
- MD5Update(&context, buffer+i, n);
- }
+ len = strlen(buffer);
+ for (i= 0; i < len; i += 16) {
+ n = (len - i) > 16 ? 16 : (len - i);
+ MD5Update(&context, buffer+i, n);
+ }
- MD5Final(&context);
+ MD5Final(&context);
- MD5result[0] = '\0';
- for (i = 0; i < 16; i++) {
- MD5result[i] = context.digest[i];
- }
+ MD5result[0] = '\0';
+ for (i = 0; i < 16; i++) {
+ MD5result[i] = context.digest[i];
+ }
}
/*--------------------------------------------------------------------------*/
@@ -214,14 +214,14 @@ void write_example_passwd(char *pwfile, char pwlocation, struct passwd *pw) {
close(i);
if ( ! (f = fopen(pwfile, "w")) )
return;
- fprintf(f, "# %s Password file for axspawn\n", (pwlocation == SYSTEMPW ? "System" : "User"));
+ fprintf(f, "# %s Password file for axspawn\n", (pwlocation == SYSTEMPW ? "System" : "User"));
if (pwlocation == SYSTEMPW) {
fprintf(f, "# disable user self-administered passwords in $HOME/.%s\n", PWFILE);
fprintf(f, "# with the line \"systempasswordonly\"\n");
fprintf(f, "# systempasswordonly\n");
}
fprintf(f, "# Examples (sys and md5 passwords may differ):\n");
- fprintf(f, "# md5 standard (secure) - length: >= %d and <= %d characters\n", MINPWLEN_MD5, PASSSIZE);
+ fprintf(f, "# md5 standard (secure) - length: >= %d and <= %d characters\n", MINPWLEN_MD5, PASSSIZE);
fprintf(f, "# %smd5:%s\n", (pwlocation == SYSTEMPW ? "username:" : ""), generate_rand_pw(MINPWLEN_MD5));
fprintf(f, "# sys/baycom standard (not very secure) - length: >= %d and <= %d characters\n", MINPWLEN_SYS, PASSSIZE);
fprintf(f, "# %ssys:%s\n", (pwlocation == SYSTEMPW ? "username:" : ""), generate_rand_pw(MINPWLEN_SYS));
@@ -357,7 +357,7 @@ char *read_pwd (struct passwd *pw, int *pwtype)
for (p = pass; *p && !isspace(*p & 0xff); p++) ;
*p = 0;
- if ( (*pwtype & PW_MD5) && !Strcasecmp(p_buf, "md5") ) {
+ if ( (*pwtype & PW_MD5) && !Strcasecmp(p_buf, "md5") ) {
fclose(f);
*pwtype = PW_MD5;
goto found;
@@ -373,7 +373,7 @@ char *read_pwd (struct passwd *pw, int *pwtype)
}
}
found:
-
+
if (!pass || !*pwtype)
goto end;
@@ -391,6 +391,6 @@ found:
end:
*pwtype = (((*pwtype) & PW_CLEARTEXT) ? PW_CLEARTEXT : 0);
- /* ^ may allow cleartext? - then cleartext, else deny */
+ /* ^ may allow cleartext? - then cleartext, else deny */
return 0;
}
diff --git a/ax25/access.h b/ax25/access.h
index 4901418..8859262 100644
--- a/ax25/access.h
+++ b/ax25/access.h
@@ -8,13 +8,12 @@
#define PWFILE "bcpasswd"
/* PWxxx: set bits */
-#define PW_CLEARTEXT 1
-#define PW_SYS 2
-#define PW_MD5 4
-#define PW_UNIX 8
+#define PW_CLEARTEXT 1
+#define PW_SYS 2
+#define PW_MD5 4
+#define PW_UNIX 8
void ask_pw_sys(char *prompt, char *pass_want, char *pw);
void ask_pw_md5(char *prompt, char *pass_want, char *pw);
char *read_pwd (struct passwd *pw, int *pwtype);
#endif
-
diff --git a/ax25/ax25.4 b/ax25/ax25.4
index 6456971..f10bc06 100644
--- a/ax25/ax25.4
+++ b/ax25/ax25.4
@@ -38,7 +38,7 @@ association. a set of ioctl calls are provided to manage an association
table, and in addition the superuser may use an arbitary callsign by binding
to the callsign desired and specifying the port to use as a first digipeated
hop.
-.LP
+.LP
AX.25 supports the following socket options for SOL_AX25. AX25_T1 is the T1
timer in 1/10ths of a second, AX25_T2 is the T2 timer in 1/10ths of a
second, AX25_T3 is the T3 timer. The window is settable with AX25_WINDOW.
diff --git a/ax25/ax25d.c b/ax25/ax25d.c
index 899e04e..4694fb9 100644
--- a/ax25/ax25d.c
+++ b/ax25/ax25d.c
@@ -71,7 +71,7 @@
* 1.6 Aug 1995 Reset the 'defaults' entry's when we start parsing
* a new interface.
*
- * 1.7 Dec 1995 Added BROKEN_NETROM_KERNEL define for setsockopt.
+ * 1.7 Dec 1995 Added BROKEN_NETROM_KERNEL define for setsockopt.
*
* 1.8 Jan 1996 Added support for AX25_BIND_ANY_DEVICE, specify just
* [CALL-X VIA *].
@@ -182,7 +182,7 @@ struct axlist { /* Have used same struct for quickness */
int LoggingVC; /* extra log stuff */
};
-static struct axlist *AXL = NULL;
+static struct axlist *AXL;
static char *ConfigFile = CONF_AX25D_FILE;
static char User[10]; /* Room for 'GB9ZZZ-15\0' */
static char Node[11]; /* Room for 'GB9ZZZ-15\0' (NETROM) and 10 bytes ROSE '6505551234\0' */
@@ -228,7 +228,7 @@ void err_config(void) {
if (Logging)
syslog(LOG_INFO, "config file reload error, continuing with original");
}
-}
+}
/*--------------------------------------------------------------------------*/
@@ -265,24 +265,24 @@ int main(int argc, char *argv[])
char buf[1024];
char *p;
char *mesg;
-
+
while ((cnt = getopt(argc, argv, "c:lv")) != EOF) {
switch (cnt) {
- case 'c':
- ConfigFile = optarg;
- break;
+ case 'c':
+ ConfigFile = optarg;
+ break;
- case 'l':
- Logging = TRUE;
- break;
+ case 'l':
+ Logging = TRUE;
+ break;
- case 'v':
- printf("ax25d: %s\n", VERSION);
- return 1;
+ case 'v':
+ printf("ax25d: %s\n", VERSION);
+ return 1;
- default:
- fprintf(stderr, "Usage: ax25d [-v] [-c altfile] [-l]\n");
- return 1;
+ default:
+ fprintf(stderr, "Usage: ax25d [-v] [-c altfile] [-l]\n");
+ return 1;
}
}
@@ -336,7 +336,7 @@ int main(int argc, char *argv[])
int argc;
int new;
int i;
-
+
/*
* Setting up a non-blocking accept() so is does not hang up
* - I am not sure at this time why I didn't/don't assign
@@ -358,7 +358,7 @@ int main(int argc, char *argv[])
i = FALSE;
ioctl(paxl->fd, FIONBIO, &i);
-
+
if (new < 0) {
if (errno == EWOULDBLOCK)
continue; /* It's gone ??? */
@@ -368,22 +368,22 @@ int main(int argc, char *argv[])
close(paxl->fd);
paxl->fd = -1;
reload_timer(10);
- continue;
+ continue;
}
switch (paxl->af_type) {
- case AF_AX25:
- strcpy(User, ax25_ntoa(&sockaddr.ax25.fsa_ax25.sax25_call));
- strcpy(Node, "");
- break;
- case AF_NETROM:
- strcpy(User, ax25_ntoa(&sockaddr.ax25.fsa_ax25.sax25_call));
- strcpy(Node, ax25_ntoa(&sockaddr.ax25.fsa_digipeater[0]));
- break;
- case AF_ROSE:
- strcpy(User, ax25_ntoa(&sockaddr.rose.srose_call));
- strcpy(Node, rose_ntoa(&sockaddr.rose.srose_addr));
- break;
+ case AF_AX25:
+ strcpy(User, ax25_ntoa(&sockaddr.ax25.fsa_ax25.sax25_call));
+ strcpy(Node, "");
+ break;
+ case AF_NETROM:
+ strcpy(User, ax25_ntoa(&sockaddr.ax25.fsa_ax25.sax25_call));
+ strcpy(Node, ax25_ntoa(&sockaddr.ax25.fsa_digipeater[0]));
+ break;
+ case AF_ROSE:
+ strcpy(User, ax25_ntoa(&sockaddr.rose.srose_call));
+ strcpy(Node, rose_ntoa(&sockaddr.rose.srose_addr));
+ break;
}
for (raxl = paxl->ents; raxl != NULL; raxl = raxl->ents) {
@@ -413,33 +413,33 @@ int main(int argc, char *argv[])
getsockname(new, (struct sockaddr *)&sockaddr, &addrlen);
switch (paxl->af_type) {
- case AF_AX25:
- Port = ax25_config_get_port(&sockaddr.ax25.fsa_digipeater[0]);
- break;
- case AF_NETROM:
- Port = nr_config_get_port(&sockaddr.ax25.fsa_ax25.sax25_call);
- break;
- case AF_ROSE:
- Port = rs_config_get_port(&sockaddr.rose.srose_addr);
- break;
- default:
- Port = "???";
- break;
+ case AF_AX25:
+ Port = ax25_config_get_port(&sockaddr.ax25.fsa_digipeater[0]);
+ break;
+ case AF_NETROM:
+ Port = nr_config_get_port(&sockaddr.ax25.fsa_ax25.sax25_call);
+ break;
+ case AF_ROSE:
+ Port = rs_config_get_port(&sockaddr.rose.srose_addr);
+ break;
+ default:
+ Port = "???";
+ break;
}
if (raxl == NULL) {
/* No default */
if (Logging && !(paxl->flags & FLAG_NOLOGGING)) {
switch (paxl->af_type) {
- case AF_AX25:
- syslog(LOG_INFO, "AX.25 %s (%s) rejected - no default", User, Port);
- break;
- case AF_NETROM:
- syslog(LOG_INFO, "NET/ROM %s@%s (%s) rejected - no default", User, Node, Port);
- break;
- case AF_ROSE:
- syslog(LOG_INFO, "Rose %s@%s (%s) rejected - no default", User, Node, Port);
- break;
+ case AF_AX25:
+ syslog(LOG_INFO, "AX.25 %s (%s) rejected - no default", User, Port);
+ break;
+ case AF_NETROM:
+ syslog(LOG_INFO, "NET/ROM %s@%s (%s) rejected - no default", User, Node, Port);
+ break;
+ case AF_ROSE:
+ syslog(LOG_INFO, "Rose %s@%s (%s) rejected - no default", User, Node, Port);
+ break;
}
}
close(new);
@@ -450,15 +450,15 @@ int main(int argc, char *argv[])
/* Not allowed to connect */
if (Logging && !(paxl->flags & FLAG_NOLOGGING)) {
switch (raxl->af_type) {
- case AF_AX25:
- syslog(LOG_INFO, "AX.25 %s (%s) rejected - port locked", User, Port);
- break;
- case AF_NETROM:
- syslog(LOG_INFO, "NET/ROM %s@%s (%s) rejected - port locked", User, Node, Port);
- break;
- case AF_ROSE:
- syslog(LOG_INFO, "Rose %s@%s (%s) rejected - port locked", User, Node, Port);
- break;
+ case AF_AX25:
+ syslog(LOG_INFO, "AX.25 %s (%s) rejected - port locked", User, Port);
+ break;
+ case AF_NETROM:
+ syslog(LOG_INFO, "NET/ROM %s@%s (%s) rejected - port locked", User, Node, Port);
+ break;
+ case AF_ROSE:
+ syslog(LOG_INFO, "Rose %s@%s (%s) rejected - port locked", User, Node, Port);
+ break;
}
}
close(new);
@@ -476,155 +476,155 @@ int main(int argc, char *argv[])
pid = fork();
switch (pid) {
- case -1:
- if (Logging)
- syslog(LOG_ERR, "fork error %m");
- /*
- * I don't think AX25 at the moment will hold the
- * connection open, if the above does not make it
- * through first time.
- */
- close(new);
- break; /* Oh well... */
+ case -1:
+ if (Logging)
+ syslog(LOG_ERR, "fork error %m");
+ /*
+ * I don't think AX25 at the moment will hold the
+ * connection open, if the above does not make it
+ * through first time.
+ */
+ close(new);
+ break; /* Oh well... */
- case 0:
+ case 0:
- if (raxl->af_type == AF_AX25 && raxl->checkVC) {
- /* to which of my own addresses has the user connected? */
- getsockname(new, (struct sockaddr *)&sockaddr, &addrlen);
- strcpy(myAX25Name, ax25_ntoa(&sockaddr.ax25.fsa_ax25.sax25_call));
+ if (raxl->af_type == AF_AX25 && raxl->checkVC) {
+ /* to which of my own addresses has the user connected? */
+ getsockname(new, (struct sockaddr *)&sockaddr, &addrlen);
+ strcpy(myAX25Name, ax25_ntoa(&sockaddr.ax25.fsa_ax25.sax25_call));
- sprintf(buf, "/usr/sbin/ax25rtctl -l ip | grep -i ' %s ' | /bin/grep 'v ' >/dev/null", User);
+ sprintf(buf, "/usr/sbin/ax25rtctl -l ip | grep -i ' %s ' | /bin/grep 'v ' >/dev/null", User);
- /* he's not a VC user? */
- if (system(buf) != 0)
- goto login;
+ /* he's not a VC user? */
+ if (system(buf) != 0)
+ goto login;
- if (raxl->checkVC > 1) {
- /* setproctitle("ax25d [%d]: rejecting, User); */
- } else {
- /* setproctitle("ax25d [%d]: %s, User, (VCloginEnable ? "waiting" : "discarding")); */
- }
+ if (raxl->checkVC > 1) {
+ /* setproctitle("ax25d [%d]: rejecting, User); */
+ } else {
+ /* setproctitle("ax25d [%d]: %s, User, (VCloginEnable ? "waiting" : "discarding")); */
+ }
- /* is a VC user. checkVC > 0? then reject now, or fork and wait for pid=textdata.. */
- if (raxl->VCsendFailureMsg) {
- sprintf(buf, "*** %s: NO MODE VC with %s\r", myAX25Name, myAX25Name);
- write(new, buf, strlen(buf));
- if (raxl->checkVC > 1)
- sleep(1);
- }
+ /* is a VC user. checkVC > 0? then reject now, or fork and wait for pid=textdata.. */
+ if (raxl->VCsendFailureMsg) {
+ sprintf(buf, "*** %s: NO MODE VC with %s\r", myAX25Name, myAX25Name);
+ write(new, buf, strlen(buf));
+ if (raxl->checkVC > 1)
+ sleep(1);
+ }
- if (raxl->checkVC > 1) {
- if (Logging && (!(paxl->flags & FLAG_NOLOGGING) || raxl->LoggingVC))
- syslog((raxl->LoggingVC ? LOG_NOTICE : LOG_INFO), "AX.25 %s (%s:%s) rejected - AX25.IP-VC entry found", User, Port, myAX25Name);
- goto close_link;
- }
+ if (raxl->checkVC > 1) {
+ if (Logging && (!(paxl->flags & FLAG_NOLOGGING) || raxl->LoggingVC))
+ syslog((raxl->LoggingVC ? LOG_NOTICE : LOG_INFO), "AX.25 %s (%s:%s) rejected - AX25.IP-VC entry found", User, Port, myAX25Name);
+ goto close_link;
+ }
- /* checkVC == 1: wait for data */
- if (Logging && (!(paxl->flags & FLAG_NOLOGGING) || raxl->LoggingVC)) {
- syslog((raxl->LoggingVC ? LOG_NOTICE : LOG_INFO), "AX.25 %s (%s:%s) AX25.IP-VC host connected. %s",
- User, Port, myAX25Name,
- (raxl->VCloginEnable ? "waiting for first PID=text packet for triggered login" : "discarding PID=text packets"));
- }
+ /* checkVC == 1: wait for data */
+ if (Logging && (!(paxl->flags & FLAG_NOLOGGING) || raxl->LoggingVC)) {
+ syslog((raxl->LoggingVC ? LOG_NOTICE : LOG_INFO), "AX.25 %s (%s:%s) AX25.IP-VC host connected. %s",
+ User, Port, myAX25Name,
+ (raxl->VCloginEnable ? "waiting for first PID=text packet for triggered login" : "discarding PID=text packets"));
+ }
- *buf = 0;
- mesg = 0;
- while ((i = read(new, buf, (sizeof(buf)-1))) > 0) {
- buf[i] = 0;
- if (Logging && raxl->LoggingVC > 1) {
- /* debug */
- syslog((LOG_DEBUG), "DEBUG: AX.25 %s (%s:%s) AX25.IP-VC host said: >%s<", User, Port, myAX25Name, buf);
- }
- /* skip leading mess */
- for (p = buf; *p && (isspace(*p & 0xff) || *p == '\r'); p++) ;
- if (raxl->VCdiscOnLinkfailureMsg && !strncmp(p, "***", 3)) {
- /* format received line for debug purposes */
- /* 1. skip "***" */
- for (p += 3; *p && isspace(*p & 0xff); p++ ) ;
- mesg = p;
- /* 2. get rid off EOL delimiters */
- while (*p) {
- if (*p == '\r' || *p == '\n') {
- *p = 0;
- break;
- }
- p++;
+ *buf = 0;
+ mesg = 0;
+ while ((i = read(new, buf, (sizeof(buf)-1))) > 0) {
+ buf[i] = 0;
+ if (Logging && raxl->LoggingVC > 1) {
+ /* debug */
+ syslog((LOG_DEBUG), "DEBUG: AX.25 %s (%s:%s) AX25.IP-VC host said: >%s<", User, Port, myAX25Name, buf);
+ }
+ /* skip leading mess */
+ for (p = buf; *p && (isspace(*p & 0xff) || *p == '\r'); p++) ;
+ if (raxl->VCdiscOnLinkfailureMsg && !strncmp(p, "***", 3)) {
+ /* format received line for debug purposes */
+ /* 1. skip "***" */
+ for (p += 3; *p && isspace(*p & 0xff); p++ ) ;
+ mesg = p;
+ /* 2. get rid off EOL delimiters */
+ while (*p) {
+ if (*p == '\r' || *p == '\n') {
+ *p = 0;
+ break;
}
- /* end read loop */
- break;
+ p++;
}
- /* per default, we discard all messages,
- * because there's no useful combination
- * using VC and pidText togegther
- */
- if (raxl->VCloginEnable)
- goto login;
+ /* end read loop */
+ break;
}
+ /* per default, we discard all messages,
+ * because there's no useful combination
+ * using VC and pidText togegther
+ */
+ if (raxl->VCloginEnable)
+ goto login;
+ }
- if (Logging && (!(paxl->flags & FLAG_NOLOGGING) || raxl->LoggingVC)) {
- syslog((raxl->LoggingVC ? LOG_NOTICE : LOG_INFO),
- "AX.25 %s (%s:%s) AX25.IP-VC host disconnected%s%s",
- User,
- Port,
- myAX25Name,
- (mesg ? ": " : "."),
- (mesg ? mesg : ""));
- }
- /* point of no return */
-close_link:
- /* close link */
- /* setproctitle("ax25d [%s]: disconnecting", User); */
- close(new);
- exit(0);
+ if (Logging && (!(paxl->flags & FLAG_NOLOGGING) || raxl->LoggingVC)) {
+ syslog((raxl->LoggingVC ? LOG_NOTICE : LOG_INFO),
+ "AX.25 %s (%s:%s) AX25.IP-VC host disconnected%s%s",
+ User,
+ Port,
+ myAX25Name,
+ (mesg ? ": " : "."),
+ (mesg ? mesg : ""));
}
+ /* point of no return */
+close_link:
+ /* close link */
+ /* setproctitle("ax25d [%s]: disconnecting", User); */
+ close(new);
+ exit(0);
+ }
login:
- /* setproctitle("ax25d [%s]: login", User); */
-
- SetupOptions(new, raxl);
- WorkoutArgs(raxl->af_type, raxl->shell, &argc, argv);
-
- if (Logging && !(paxl->flags & FLAG_NOLOGGING)) {
- switch (paxl->af_type) {
- case AF_AX25:
- syslog(LOG_INFO, "AX.25 %s (%s) %s", User, Port, argv[0]);
- break;
- case AF_NETROM:
- syslog(LOG_INFO, "NET/ROM %s@%s (%s) %s", User, Node, Port, argv[0]);
- break;
- case AF_ROSE:
- syslog(LOG_INFO, "Rose %s@%s (%s) %s", User, Node, Port, argv[0]);
- break;
- }
+ /* setproctitle("ax25d [%s]: login", User); */
+
+ SetupOptions(new, raxl);
+ WorkoutArgs(raxl->af_type, raxl->shell, &argc, argv);
+
+ if (Logging && !(paxl->flags & FLAG_NOLOGGING)) {
+ switch (paxl->af_type) {
+ case AF_AX25:
+ syslog(LOG_INFO, "AX.25 %s (%s) %s", User, Port, argv[0]);
+ break;
+ case AF_NETROM:
+ syslog(LOG_INFO, "NET/ROM %s@%s (%s) %s", User, Node, Port, argv[0]);
+ break;
+ case AF_ROSE:
+ syslog(LOG_INFO, "Rose %s@%s (%s) %s", User, Node, Port, argv[0]);
+ break;
}
+ }
- dup2(new, STDIN_FILENO);
- dup2(new, STDOUT_FILENO);
- close(new);
+ dup2(new, STDIN_FILENO);
+ dup2(new, STDOUT_FILENO);
+ close(new);
+
+ /*
+ * Might be more efficient if we just went down AXL,
+ * we cleaned up our parents left overs on bootup.
+ */
+ for (axltmp = AXL; axltmp != NULL; axltmp = axltmp->next)
+ close(axltmp->fd);
- /*
- * Might be more efficient if we just went down AXL,
- * we cleaned up our parents left overs on bootup.
- */
- for (axltmp = AXL; axltmp != NULL; axltmp = axltmp->next)
- close(axltmp->fd);
-
- if (Logging)
- closelog();
-
- /* Make root secure, before we exec() */
- /* Strip any supplementary gid's */
- if (setgroups(0, grps) == -1)
- exit(1);
- if (setgid(raxl->gid) == -1)
- exit(1);
- if (setuid(raxl->uid) == -1)
- exit(1);
- execve(raxl->exec, argv, NULL);
+ if (Logging)
+ closelog();
+
+ /* Make root secure, before we exec() */
+ /* Strip any supplementary gid's */
+ if (setgroups(0, grps) == -1)
+ exit(1);
+ if (setgid(raxl->gid) == -1)
exit(1);
+ if (setuid(raxl->uid) == -1)
+ exit(1);
+ execve(raxl->exec, argv, NULL);
+ exit(1);
- default:
- close(new);
- break;
+ default:
+ close(new);
+ break;
}
}
}
@@ -645,7 +645,7 @@ static void SignalTERM(int code)
syslog(LOG_INFO, "terminating on SIGTERM\n");
closelog();
}
-
+
exit(0);
}
@@ -655,7 +655,7 @@ static void WorkoutArgs(int af_type, char *shell, int *argc, char **argv)
char *sp, *cp;
int cnt = 0;
int args = 0;
-
+
for (cp = shell; *cp != '\0'; cp++) {
if (isspace(*cp) && cnt != 0) {
buffer[cnt] = '\0';
@@ -675,73 +675,73 @@ static void WorkoutArgs(int af_type, char *shell, int *argc, char **argv)
if (*cp == '%') {
cp++;
- switch(*cp) {
- case 'd': /* portname */
- for (sp = Port; *sp != '\0' && *sp != '-'; sp++)
- buffer[cnt++] = *sp;
- break;
-
- case 'U': /* username in UPPER */
- for (sp = User; *sp != '\0' && *sp != '-'; sp++)
- buffer[cnt++] = toupper(*sp);
- break;
+ switch (*cp) {
+ case 'd': /* portname */
+ for (sp = Port; *sp != '\0' && *sp != '-'; sp++)
+ buffer[cnt++] = *sp;
+ break;
- case 'u': /* USERNAME IN lower */
- for (sp = User; *sp != '\0' && *sp != '-'; sp++)
- buffer[cnt++] = tolower(*sp);
- break;
+ case 'U': /* username in UPPER */
+ for (sp = User; *sp != '\0' && *sp != '-'; sp++)
+ buffer[cnt++] = toupper(*sp);
+ break;
- case 'S': /* username in UPPER (with SSID) */
- for (sp = User; *sp != '\0'; sp++)
- buffer[cnt++] = toupper(*sp);
- break;
+ case 'u': /* USERNAME IN lower */
+ for (sp = User; *sp != '\0' && *sp != '-'; sp++)
+ buffer[cnt++] = tolower(*sp);
+ break;
- case 's': /* USERNAME IN lower (with SSID) */
- for (sp = User; *sp != '\0'; sp++)
- buffer[cnt++] = tolower(*sp);
- break;
+ case 'S': /* username in UPPER (with SSID) */
+ for (sp = User; *sp != '\0'; sp++)
+ buffer[cnt++] = toupper(*sp);
+ break;
- case 'P': /* nodename in UPPER */
- if (af_type == AF_NETROM) {
- for (sp = Node; *sp != '\0' && *sp != '-'; sp++)
- buffer[cnt++] = toupper(*sp);
- } else {
- buffer[cnt++] = '%';
- }
- break;
+ case 's': /* USERNAME IN lower (with SSID) */
+ for (sp = User; *sp != '\0'; sp++)
+ buffer[cnt++] = tolower(*sp);
+ break;
- case 'p': /* NODENAME IN lower */
- if (af_type == AF_NETROM) {
- for(sp = Node; *sp != '\0' && *sp != '-'; sp++)
- buffer[cnt++] = tolower(*sp);
- } else {
- buffer[cnt++] = '%';
- }
- break;
+ case 'P': /* nodename in UPPER */
+ if (af_type == AF_NETROM) {
+ for (sp = Node; *sp != '\0' && *sp != '-'; sp++)
+ buffer[cnt++] = toupper(*sp);
+ } else {
+ buffer[cnt++] = '%';
+ }
+ break;
- case 'R': /* nodename in UPPER (with SSID) */
- if (af_type == AF_NETROM) {
- for (sp = Node; *sp != '\0'; sp++)
- buffer[cnt++] = toupper(*sp);
- } else {
- buffer[cnt++] = '%';
- }
- break;
+ case 'p': /* NODENAME IN lower */
+ if (af_type == AF_NETROM) {
+ for (sp = Node; *sp != '\0' && *sp != '-'; sp++)
+ buffer[cnt++] = tolower(*sp);
+ } else {
+ buffer[cnt++] = '%';
+ }
+ break;
- case 'r': /* NODENAME IN lower (with SSID) */
- if (af_type == AF_NETROM) {
- for (sp = Node; *sp != '\0'; sp++)
- buffer[cnt++] = tolower(*sp);
- } else {
- buffer[cnt++] = '%';
- }
- break;
+ case 'R': /* nodename in UPPER (with SSID) */
+ if (af_type == AF_NETROM) {
+ for (sp = Node; *sp != '\0'; sp++)
+ buffer[cnt++] = toupper(*sp);
+ } else {
+ buffer[cnt++] = '%';
+ }
+ break;
- case '\0':
- case '%':
- default:
+ case 'r': /* NODENAME IN lower (with SSID) */
+ if (af_type == AF_NETROM) {
+ for (sp = Node; *sp != '\0'; sp++)
+ buffer[cnt++] = tolower(*sp);
+ } else {
buffer[cnt++] = '%';
- break;
+ }
+ break;
+
+ case '\0':
+ case '%':
+ default:
+ buffer[cnt++] = '%';
+ break;
}
} else {
buffer[cnt++] = *cp;
@@ -829,33 +829,33 @@ static int ReadConfig(void)
if (buffer[0] == '#')
continue;
-
- switch (buffer[0]) {
- case '[': /* AX25 port call */
- af_type = AF_AX25;
- hunt = TRUE;
- error = FALSE;
- iamdigi = FALSE;
- break;
-
- case '<': /* NETROM iface call */
- af_type = AF_NETROM;
- hunt = TRUE;
- error = FALSE;
- iamdigi = FALSE;
- break;
- case '{': /* ROSE iface call */
- af_type = AF_ROSE;
- hunt = TRUE;
- error = FALSE;
- iamdigi = FALSE;
- break;
-
- default:
- if (hunt && !error)
- goto BadLine;
- break;
+ switch (buffer[0]) {
+ case '[': /* AX25 port call */
+ af_type = AF_AX25;
+ hunt = TRUE;
+ error = FALSE;
+ iamdigi = FALSE;
+ break;
+
+ case '<': /* NETROM iface call */
+ af_type = AF_NETROM;
+ hunt = TRUE;
+ error = FALSE;
+ iamdigi = FALSE;
+ break;
+
+ case '{': /* ROSE iface call */
+ af_type = AF_ROSE;
+ hunt = TRUE;
+ error = FALSE;
+ iamdigi = FALSE;
+ break;
+
+ default:
+ if (hunt && !error)
+ goto BadLine;
+ break;
}
if (hunt) { /* We've found a Iface entry */
@@ -863,104 +863,104 @@ static int ReadConfig(void)
memset(&axl_defaults, 0, sizeof(axl_defaults));
switch (af_type) {
- case AF_AX25:
- if ((s = strchr(buffer, ']')) == NULL)
- goto BadLine;
- *s = '\0';
- if ((s = strtok(buffer + 1, " \t")) == NULL)
- goto BadLine;
- port = s;
- call = NULL;
- if ((s = strtok(NULL, " \t")) != NULL) {
- if (strcasecmp(s, "VIA") == 0 || strcasecmp(s, "V") == 0) {
- if ((s = strtok(NULL, " \t")) == NULL)
- goto BadLine;
- }
+ case AF_AX25:
+ if ((s = strchr(buffer, ']')) == NULL)
+ goto BadLine;
+ *s = '\0';
+ if ((s = strtok(buffer + 1, " \t")) == NULL)
+ goto BadLine;
+ port = s;
+ call = NULL;
+ if ((s = strtok(NULL, " \t")) != NULL) {
+ if (strcasecmp(s, "VIA") == 0 || strcasecmp(s, "V") == 0) {
+ if ((s = strtok(NULL, " \t")) == NULL)
+ goto BadLine;
+ }
- call = port;
- port = s;
+ call = port;
+ port = s;
- if ((s = strchr(call, '*')) != NULL) {
- iamdigi = TRUE;
- *s = '\0';
- }
- }
- if (strcmp(port, "*") == 0 && call == NULL) {
- fprintf(stderr, "ax25d: invalid port name\n");
- continue;
+ if ((s = strchr(call, '*')) != NULL) {
+ iamdigi = TRUE;
+ *s = '\0';
}
- if (strcmp(port, "*") != 0) {
- if ((addr = ax25_config_get_addr(port)) == NULL) {
- fprintf(stderr, "ax25d: invalid AX.25 port '%s'\n", port);
- continue;
- }
- }
- if (call == NULL) {
- sockaddr.ax25.fsa_ax25.sax25_family = AF_AX25;
- sockaddr.ax25.fsa_ax25.sax25_ndigis = 0;
- ax25_aton_entry(addr, sockaddr.ax25.fsa_ax25.sax25_call.ax25_call);
- } else {
- sockaddr.ax25.fsa_ax25.sax25_family = AF_AX25;
- sockaddr.ax25.fsa_ax25.sax25_ndigis = 1;
- ax25_aton_entry(call, sockaddr.ax25.fsa_ax25.sax25_call.ax25_call);
- if (strcmp(port, "*") != 0)
- ax25_aton_entry(addr, sockaddr.ax25.fsa_digipeater[0].ax25_call);
- else
- sockaddr.ax25.fsa_digipeater[0] = null_ax25_address;
- }
- addrlen = sizeof(struct full_sockaddr_ax25);
- break;
-
- case AF_NETROM:
- if ((s = strchr(buffer, '>')) == NULL)
- goto BadLine;
- *s = '\0';
- port = buffer + 1;
- if ((addr = nr_config_get_addr(port)) == NULL) {
- fprintf(stderr, "ax25d: invalid NET/ROM port '%s'\n", port);
+ }
+ if (strcmp(port, "*") == 0 && call == NULL) {
+ fprintf(stderr, "ax25d: invalid port name\n");
+ continue;
+ }
+ if (strcmp(port, "*") != 0) {
+ if ((addr = ax25_config_get_addr(port)) == NULL) {
+ fprintf(stderr, "ax25d: invalid AX.25 port '%s'\n", port);
continue;
}
- sockaddr.ax25.fsa_ax25.sax25_family = AF_NETROM;
+ }
+ if (call == NULL) {
+ sockaddr.ax25.fsa_ax25.sax25_family = AF_AX25;
sockaddr.ax25.fsa_ax25.sax25_ndigis = 0;
ax25_aton_entry(addr, sockaddr.ax25.fsa_ax25.sax25_call.ax25_call);
- addrlen = sizeof(struct full_sockaddr_ax25);
- break;
+ } else {
+ sockaddr.ax25.fsa_ax25.sax25_family = AF_AX25;
+ sockaddr.ax25.fsa_ax25.sax25_ndigis = 1;
+ ax25_aton_entry(call, sockaddr.ax25.fsa_ax25.sax25_call.ax25_call);
+ if (strcmp(port, "*") != 0)
+ ax25_aton_entry(addr, sockaddr.ax25.fsa_digipeater[0].ax25_call);
+ else
+ sockaddr.ax25.fsa_digipeater[0] = null_ax25_address;
+ }
+ addrlen = sizeof(struct full_sockaddr_ax25);
+ break;
- case AF_ROSE:
- if ((s = strchr(buffer, '}')) == NULL)
- goto BadLine;
- *s = '\0';
- if ((s = strtok(buffer + 1, " \t")) == NULL)
- goto BadLine;
- call = s;
+ case AF_NETROM:
+ if ((s = strchr(buffer, '>')) == NULL)
+ goto BadLine;
+ *s = '\0';
+ port = buffer + 1;
+ if ((addr = nr_config_get_addr(port)) == NULL) {
+ fprintf(stderr, "ax25d: invalid NET/ROM port '%s'\n", port);
+ continue;
+ }
+ sockaddr.ax25.fsa_ax25.sax25_family = AF_NETROM;
+ sockaddr.ax25.fsa_ax25.sax25_ndigis = 0;
+ ax25_aton_entry(addr, sockaddr.ax25.fsa_ax25.sax25_call.ax25_call);
+ addrlen = sizeof(struct full_sockaddr_ax25);
+ break;
+
+ case AF_ROSE:
+ if ((s = strchr(buffer, '}')) == NULL)
+ goto BadLine;
+ *s = '\0';
+ if ((s = strtok(buffer + 1, " \t")) == NULL)
+ goto BadLine;
+ call = s;
+ if ((s = strtok(NULL, " \t")) == NULL)
+ goto BadLine;
+ if (strcasecmp(s, "VIA") == 0 || strcasecmp(s, "V") == 0) {
if ((s = strtok(NULL, " \t")) == NULL)
goto BadLine;
- if (strcasecmp(s, "VIA") == 0 || strcasecmp(s, "V") == 0) {
- if ((s = strtok(NULL, " \t")) == NULL)
- goto BadLine;
- }
- port = s;
- if ((addr = rs_config_get_addr(port)) == NULL) {
- fprintf(stderr, "ax25d: invalid Rose port '%s'\n", port);
- continue;
- }
- if (strcmp(call, "*") == 0) {
- sockaddr.rose.srose_family = AF_ROSE;
- sockaddr.rose.srose_ndigis = 0;
- rose_aton(addr, sockaddr.rose.srose_addr.rose_addr);
- sockaddr.rose.srose_call = null_ax25_address;
- } else {
- sockaddr.rose.srose_family = AF_ROSE;
- sockaddr.rose.srose_ndigis = 0;
- rose_aton(addr, sockaddr.rose.srose_addr.rose_addr);
- ax25_aton_entry(call, sockaddr.rose.srose_call.ax25_call);
- }
- addrlen = sizeof(struct sockaddr_rose);
- break;
+ }
+ port = s;
+ if ((addr = rs_config_get_addr(port)) == NULL) {
+ fprintf(stderr, "ax25d: invalid Rose port '%s'\n", port);
+ continue;
+ }
+ if (strcmp(call, "*") == 0) {
+ sockaddr.rose.srose_family = AF_ROSE;
+ sockaddr.rose.srose_ndigis = 0;
+ rose_aton(addr, sockaddr.rose.srose_addr.rose_addr);
+ sockaddr.rose.srose_call = null_ax25_address;
+ } else {
+ sockaddr.rose.srose_family = AF_ROSE;
+ sockaddr.rose.srose_ndigis = 0;
+ rose_aton(addr, sockaddr.rose.srose_addr.rose_addr);
+ ax25_aton_entry(call, sockaddr.rose.srose_call.ax25_call);
+ }
+ addrlen = sizeof(struct sockaddr_rose);
+ break;
- default:
- fprintf(stderr, "ax25d: unknown af_type=%d\n", af_type);
- exit(1);
+ default:
+ fprintf(stderr, "ax25d: unknown af_type=%d\n", af_type);
+ exit(1);
}
if ((axl_port = calloc(1, sizeof(*axl_port))) == NULL) {
@@ -979,13 +979,13 @@ static int ReadConfig(void)
reload_timer(60);
continue;
}
- /* xlz - have to nuke this as this option is gone
- * what should be here?
+ /* xlz - have to nuke this as this option is gone
+ * what should be here?
if (iamdigi) {
yes = 1;
setsockopt(axl_port->fd, SOL_AX25, AX25_IAMDIGI, &yes, sizeof(yes));
}
- */
+ */
if (bind(axl_port->fd, (struct sockaddr *)&sockaddr, addrlen) < 0) {
fprintf(stderr, "ax25d: bind: %s on port %s\n", strerror(errno), axl_port->port);
@@ -1210,7 +1210,7 @@ ignore:
goto BadArgsFree;
axl_ent->flags = ParseFlags(s, line);
-
+
if (!(axl_ent->flags & FLAG_LOCKOUT)) {
/* Get username */
if ((s = strtok(NULL, " \t")) == NULL)
@@ -1298,39 +1298,39 @@ static unsigned long ParseFlags(const char *kp, int line)
for (; *kp != '\0'; kp++) {
switch (*kp) {
- case 'v':
- case 'V':
- flags |= FLAG_VALIDCALL;
- break;
-
- case 'q':
- case 'Q':
- flags |= FLAG_NOLOGGING;
- break;
-
- case 'n':
- case 'N':
- flags |= FLAG_CHKNRN;
- break;
-
- case 'd':
- case 'D':
- flags |= FLAG_NODIGIS;
- break;
-
- case 'l':
- case 'L':
- flags |= FLAG_LOCKOUT;
- break;
-
- case '0':
- case '*':
- case '-': /* Be compatible and allow markers */
- break;
-
- default:
- fprintf(stderr, "ax25d: config file line %d bad flag option '%c'.\n", line, *kp);
- break;
+ case 'v':
+ case 'V':
+ flags |= FLAG_VALIDCALL;
+ break;
+
+ case 'q':
+ case 'Q':
+ flags |= FLAG_NOLOGGING;
+ break;
+
+ case 'n':
+ case 'N':
+ flags |= FLAG_CHKNRN;
+ break;
+
+ case 'd':
+ case 'D':
+ flags |= FLAG_NODIGIS;
+ break;
+
+ case 'l':
+ case 'L':
+ flags |= FLAG_LOCKOUT;
+ break;
+
+ case '0':
+ case '*':
+ case '-': /* Be compatible and allow markers */
+ break;
+
+ default:
+ fprintf(stderr, "ax25d: config file line %d bad flag option '%c'.\n", line, *kp);
+ break;
}
}
@@ -1340,7 +1340,7 @@ static unsigned long ParseFlags(const char *kp, int line)
static struct axlist *ClearList(struct axlist *list)
{
struct axlist *tp1, *tp2, *tmp;
-
+
for (tp1 = list; tp1 != NULL; ) {
for (tp2 = tp1->ents; tp2 != NULL; ) {
if (tp2->port != NULL)
@@ -1384,11 +1384,11 @@ static char *stripssid(const char *call)
{
static char newcall[10];
char *s;
-
+
strcpy(newcall, call);
if ((s = strchr(newcall, '-')) != NULL)
*s = '\0';
-
+
return newcall;
}
diff --git a/ax25/axctl.c b/ax25/axctl.c
index 3186229..f1116a7 100644
--- a/ax25/axctl.c
+++ b/ax25/axctl.c
@@ -23,7 +23,7 @@ int main(int argc, char **argv)
struct ax25_ctl_struct ax25_ctl;
char *addr;
int s;
-
+
if (argc == 2 && strncmp(argv[1], "-v", 2) == 0) {
printf("axctl: %s\n", VERSION);
return 0;
@@ -50,7 +50,7 @@ int main(int argc, char **argv)
return 1;
if (ax25_aton_entry(argv[3], (char *)&ax25_ctl.source_addr) == -1)
return 1;
-
+
if ((s = socket(AF_AX25, SOCK_SEQPACKET, 0)) < 0) {
perror("axctl: socket");
return 1;
@@ -65,7 +65,7 @@ int main(int argc, char **argv)
return 1;
}
ax25_ctl.arg = atoi(argv[5]);
-
+
if (strcmp(argv[4], "t1") == 0 || strcmp(argv[4], "-t1") == 0)
ax25_ctl.cmd = AX25_T1;
else if (strcmp(argv[4], "t2") == 0 || strcmp(argv[4], "-t2") == 0)
@@ -83,12 +83,11 @@ int main(int argc, char **argv)
}
ax25_ctl.digi_count = 0;
-
+
if (ioctl(s, SIOCAX25CTLCON, &ax25_ctl) != 0) {
perror("axctl: SIOCAX25CTLCON");
return 1;
}
-
+
return 0;
}
-
diff --git a/ax25/axgetput/Makefile.am b/ax25/axgetput/Makefile.am
index d3f8f8f..de92dda 100644
--- a/ax25/axgetput/Makefile.am
+++ b/ax25/axgetput/Makefile.am
@@ -1,20 +1,19 @@
installconf:
-etcfiles =
-varfiles =
+etcfiles =
+varfiles =
-sbin_PROGRAMS =
+sbin_PROGRAMS =
bin_PROGRAMS = axgetput
-man_MANS = axgetput.1
-EXTRA_DIST = $(man_MANS)
+dist_man_MANS = axgetput.1
axgetput_SOURCES = axgetput.c axgetput.h util.h proto_bin.h util.c proto_bin.c includes.h
install-exec-hook:
(cd $(DESTDIR)$(bindir) && ln -sf axgetput bget && ln -sf axgetput bput)
-install-data-hook:
+install-data-hook:
(cd $(DESTDIR)$(mandir)/man1 && ln -sf axgetput.1 bget.1 && ln -sf axgetput.1 bput.1)
diff --git a/ax25/axgetput/axgetput.c b/ax25/axgetput/axgetput.c
index d3d3f53..de21bc5 100644
--- a/ax25/axgetput/axgetput.c
+++ b/ax25/axgetput/axgetput.c
@@ -24,25 +24,25 @@
#include "util.h"
#include "proto_bin.h"
-int fdin = 0;
+int fdin;
int fdout = 1;
int fderr = 2;
-int fdout_is_pipe = 0;
-int fdin_is_pipe = 0;
+int fdout_is_pipe;
+int fdin_is_pipe;
-int is_stream = 0;
-int mode = 0;
-int do_crc_only = 0;
+int is_stream;
+int mode;
+int do_crc_only;
char c_eol = '\n';
unsigned int BLOCKSIZ = BLOCKSIZ_DEFAULT;
-char *send_on_signal = 0;
+char *send_on_signal;
static struct termios prev_termios;
-static int prev_termios_stored = 0;
-static mode_t mode_tty = 0;
+static int prev_termios_stored;
+static mode_t mode_tty;
#ifndef MYNAME
#define MYNAME "axgetput"
@@ -52,92 +52,92 @@ static mode_t mode_tty = 0;
static void set_tty_flags(void)
{
- struct termios termios;
- struct stat statbuf;
-
- if (fdin_is_pipe)
- return;
- /* mesg no */
- if (!fstat(fdin, &statbuf)) {
- /* save old mode */
- mode_tty = statbuf.st_mode;
- fchmod(fdin, 0600);
- }
- /* make tty 8bit clean */
- if (tcgetattr(fdin, &prev_termios) != -1)
- prev_termios_stored = 1;
- memset((char *) &termios, 0, sizeof(termios));
- termios.c_iflag = IGNBRK | IGNPAR;
- termios.c_oflag = 0;
- termios.c_cflag = CBAUD | CS8 | CREAD | CLOCAL;
- termios.c_cflag = ~(CSTOPB|PARENB|PARODD|HUPCL);
- termios.c_lflag = 0;
- termios.c_cc[VMIN] = 1;
- termios.c_cc[VTIME] = 0;
- termios.c_cc[VSTART] = -1;
- termios.c_cc[VSTOP] = -1;
- tcsetattr(fdin, TCSANOW, &termios);
+ struct termios termios;
+ struct stat statbuf;
+
+ if (fdin_is_pipe)
+ return;
+ /* mesg no */
+ if (!fstat(fdin, &statbuf)) {
+ /* save old mode */
+ mode_tty = statbuf.st_mode;
+ fchmod(fdin, 0600);
+ }
+ /* make tty 8bit clean */
+ if (tcgetattr(fdin, &prev_termios) != -1)
+ prev_termios_stored = 1;
+ memset((char *) &termios, 0, sizeof(termios));
+ termios.c_iflag = IGNBRK | IGNPAR;
+ termios.c_oflag = 0;
+ termios.c_cflag = CBAUD | CS8 | CREAD | CLOCAL;
+ termios.c_cflag = ~(CSTOPB|PARENB|PARODD|HUPCL);
+ termios.c_lflag = 0;
+ termios.c_cc[VMIN] = 1;
+ termios.c_cc[VTIME] = 0;
+ termios.c_cc[VSTART] = -1;
+ termios.c_cc[VSTOP] = -1;
+ tcsetattr(fdin, TCSANOW, &termios);
}
/*---------------------------------------------------------------------------*/
static void restore_tty_flags(void)
{
- if (fdin_is_pipe)
- return;
- if (prev_termios_stored)
- tcsetattr(fdin, TCSANOW, &prev_termios);
- if (mode_tty)
- fchmod(fdin, mode_tty);
+ if (fdin_is_pipe)
+ return;
+ if (prev_termios_stored)
+ tcsetattr(fdin, TCSANOW, &prev_termios);
+ if (mode_tty)
+ fchmod(fdin, mode_tty);
}
/*---------------------------------------------------------------------------*/
static void eol_convention(int state_should)
{
- /* need patched axspawn */
+ /* need patched axspawn */
#define BIN_ON "//BIN ON\r"
#define BIN_OFF "//BIN OFF\r"
- static int state_is = 0;
+ static int state_is;
- /* already in correct state? */
- if ((state_is && state_should) || (!state_is && !state_should))
- return;
+ /* already in correct state? */
+ if ((state_is && state_should) || (!state_is && !state_should))
+ return;
- sleep(1);
+ sleep(1);
- if (state_should) {
- write(fderr, BIN_ON, strlen(BIN_ON));
- c_eol = '\r';
- } else {
- write(fderr, BIN_OFF, strlen(BIN_OFF));
- c_eol = '\n';
- }
- state_is = state_should;
+ if (state_should) {
+ write(fderr, BIN_ON, strlen(BIN_ON));
+ c_eol = '\r';
+ } else {
+ write(fderr, BIN_OFF, strlen(BIN_OFF));
+ c_eol = '\n';
+ }
+ state_is = state_should;
- sleep(1);
+ sleep(1);
}
/*---------------------------------------------------------------------------*/
static void restore_defaults(void)
{
- eol_convention(0);
- restore_tty_flags();
+ eol_convention(0);
+ restore_tty_flags();
}
/*---------------------------------------------------------------------------*/
static void signal_handler(int sig)
{
- if (send_on_signal)
- secure_write(fdout, send_on_signal, strlen(send_on_signal));
- restore_defaults();
- if (*err_msg) {
- fputs(err_msg, stderr);
- }
- fprintf(stderr, "Died by signal %d.\n", sig);
- exit(sig);
+ if (send_on_signal)
+ secure_write(fdout, send_on_signal, strlen(send_on_signal));
+ restore_defaults();
+ if (*err_msg) {
+ fputs(err_msg, stderr);
+ }
+ fprintf(stderr, "Died by signal %d.\n", sig);
+ exit(sig);
}
/*---------------------------------------------------------------------------*/
@@ -153,40 +153,40 @@ void do_version(void)
/*---------------------------------------------------------------------------*/
static void usage(int all) {
- fprintf(stderr, "usage: %s ", myname);
- if (mode % 2) {
- fprintf(stderr, "[-ivh] [filename]\n");
- } else {
- fprintf(stderr, "[-isvh] [-b <blocksize>] [filename]\n");
- }
- fprintf(stderr, " -h prints detailed help\n");
- fprintf(stderr, " -i computes checksum only\n");
- fprintf(stderr, " -v prints version and exits\n");
- if (!all)
- return;
- if (mode % 2) {
- fprintf(stderr, " filename is usually got from the remote side by the protocol\n");
- fprintf(stderr, " but can be forced if you like to ignore this.\n");
- fprintf(stderr, " filename should be ommitted if output is sent to a pipe\n.");
- } else {
- fprintf(stderr, " -b value is the blocksize (framelen) of the transmitted data\n");
- fprintf(stderr, " default %d, which is a useful choice for ampr ax25.\n", BLOCKSIZ_DEFAULT);
- fprintf(stderr, " -s indicates a stream with unknown size.\n");
- fprintf(stderr, " otherwise, the data will be read to memory until EOF.\n");
- fprintf(stderr, " -s is only available if stdin is a pipe\n");
- fprintf(stderr, " if filename specified in filter, the given name will be suggested instead.\n");
- fprintf(stderr, " filename may be ommited if used as filter.\n");
- }
- fputc('\n', stderr);
- fprintf(stderr, "Tips: - compressed download:\n");
- fprintf(stderr, " gzip -c foo.txt | bget foo.txt.gz\n");
- fprintf(stderr, " tar cjf - ~/foo ~/bar/ | bget my_data.tar.bz2\n");
- fputc('\n', stderr);
- fprintf(stderr, "Other protocols:\n");
- fprintf(stderr, " bget / bput: receive / send with #BIN# protocol\n");
- fprintf(stderr, " yget / yput: receive / send with yapp\n");
- fprintf(stderr, " rget / rput: receive / send with didadit\n");
- fprintf(stderr, "These are (sym)links to one program: " MYNAME "\n");
+ fprintf(stderr, "usage: %s ", myname);
+ if (mode % 2) {
+ fprintf(stderr, "[-ivh] [filename]\n");
+ } else {
+ fprintf(stderr, "[-isvh] [-b <blocksize>] [filename]\n");
+ }
+ fprintf(stderr, " -h prints detailed help\n");
+ fprintf(stderr, " -i computes checksum only\n");
+ fprintf(stderr, " -v prints version and exits\n");
+ if (!all)
+ return;
+ if (mode % 2) {
+ fprintf(stderr, " filename is usually got from the remote side by the protocol\n");
+ fprintf(stderr, " but can be forced if you like to ignore this.\n");
+ fprintf(stderr, " filename should be ommitted if output is sent to a pipe\n.");
+ } else {
+ fprintf(stderr, " -b value is the blocksize (framelen) of the transmitted data\n");
+ fprintf(stderr, " default %d, which is a useful choice for ampr ax25.\n", BLOCKSIZ_DEFAULT);
+ fprintf(stderr, " -s indicates a stream with unknown size.\n");
+ fprintf(stderr, " otherwise, the data will be read to memory until EOF.\n");
+ fprintf(stderr, " -s is only available if stdin is a pipe\n");
+ fprintf(stderr, " if filename specified in filter, the given name will be suggested instead.\n");
+ fprintf(stderr, " filename may be ommited if used as filter.\n");
+ }
+ fputc('\n', stderr);
+ fprintf(stderr, "Tips: - compressed download:\n");
+ fprintf(stderr, " gzip -c foo.txt | bget foo.txt.gz\n");
+ fprintf(stderr, " tar cjf - ~/foo ~/bar/ | bget my_data.tar.bz2\n");
+ fputc('\n', stderr);
+ fprintf(stderr, "Other protocols:\n");
+ fprintf(stderr, " bget / bput: receive / send with #BIN# protocol\n");
+ fprintf(stderr, " yget / yput: receive / send with yapp\n");
+ fprintf(stderr, " rget / rput: receive / send with didadit\n");
+ fprintf(stderr, "These are (sym)links to one program: " MYNAME "\n");
}
@@ -203,191 +203,190 @@ static int rput(void) { strcpy(err_msg, "yapp: not implementet yet\n"); return 1
int main(int argc, char *argv[])
{
- int len;
- int ret = 0;
- int c;
- char *p;
-
- /* determine what to so in the way how we are called */
- if ((p = strrchr(argv[0], '/')))
- p++; /* skip '/' */
- else
- p = argv[0];
- len = strlen(p);
- if (len < 0 || len > sizeof(myname)-1)
- len = sizeof(myname)-1;
- strncpy(myname, p, len);
- myname[len] = 0;
- strlwc(myname);
-
- fdin_is_pipe = (isatty(fdin) ? 0 : 1);
- fdout_is_pipe = (isatty(fdout) ? 0 : 1);
-
- if (fdin_is_pipe && fdout_is_pipe) {
- fprintf(stderr, "error: cannot work in between two pipes\n");
- exit(1);
- }
-
- *filename = 0;
- *err_msg = 0;
-
- if (!strcmp(myname, "bput"))
- mode = RECV_BIN;
- else if (!strcmp(myname, "bget"))
- mode = SEND_BIN;
- else if (!strcmp(myname, "yput"))
- mode = RECV_YAPP;
- else if (!strcmp(myname, "yget"))
- mode = SEND_YAPP;
- else if (!strcmp(myname, "rput"))
- mode = RECV_DIDADIT;
- else if (!strcmp(myname, "rget"))
- mode = SEND_DIDADIT;
-
- if (mode % 2) {
- if (fdin_is_pipe) {
- fprintf(stderr, "error: error: stdin must be a tty\n");
- exit(1);
- }
- } else {
- if (fdout_is_pipe) {
- fprintf(stderr, "error: stdout must be a tty\n");
- exit(1);
- }
- }
-
- signal(SIGHUP, signal_handler);
- signal(SIGTERM, signal_handler);
- signal(SIGINT, signal_handler);
+ int len;
+ int ret = 0;
+ int c;
+ char *p;
+
+ /* determine what to so in the way how we are called */
+ if ((p = strrchr(argv[0], '/')))
+ p++; /* skip '/' */
+ else
+ p = argv[0];
+ len = strlen(p);
+ if (len < 0 || len > sizeof(myname)-1)
+ len = sizeof(myname)-1;
+ strncpy(myname, p, len);
+ myname[len] = 0;
+ strlwc(myname);
+
+ fdin_is_pipe = (isatty(fdin) ? 0 : 1);
+ fdout_is_pipe = (isatty(fdout) ? 0 : 1);
+
+ if (fdin_is_pipe && fdout_is_pipe) {
+ fprintf(stderr, "error: cannot work in between two pipes\n");
+ exit(1);
+ }
+
+ *filename = 0;
+ *err_msg = 0;
+
+ if (!strcmp(myname, "bput"))
+ mode = RECV_BIN;
+ else if (!strcmp(myname, "bget"))
+ mode = SEND_BIN;
+ else if (!strcmp(myname, "yput"))
+ mode = RECV_YAPP;
+ else if (!strcmp(myname, "yget"))
+ mode = SEND_YAPP;
+ else if (!strcmp(myname, "rput"))
+ mode = RECV_DIDADIT;
+ else if (!strcmp(myname, "rget"))
+ mode = SEND_DIDADIT;
+
+ if (mode % 2) {
+ if (fdin_is_pipe) {
+ fprintf(stderr, "error: error: stdin must be a tty\n");
+ exit(1);
+ }
+ } else {
+ if (fdout_is_pipe) {
+ fprintf(stderr, "error: stdout must be a tty\n");
+ exit(1);
+ }
+ }
+
+ signal(SIGHUP, signal_handler);
+ signal(SIGTERM, signal_handler);
+ signal(SIGINT, signal_handler);
/* for difference betreen "bput -f file" and "bget file" */
-#define get_filename(f) { \
- if (!strcmp(f, "-")) { \
- if (mode % 2) \
- fdin_is_pipe = 1; \
- else \
- fdout_is_pipe = 1; \
- } else { \
- strncpy(filename, f, sizeof(filename)-1); \
- filename[sizeof(filename)-1] = 0; \
- if (mode % 2) { \
- if (fdin_is_pipe) \
- fdin_is_pipe = 0; \
- } else { \
- if (fdout_is_pipe) \
- fdout_is_pipe = 0; \
- } \
- } \
+#define get_filename(f) { \
+ if (!strcmp(f, "-")) { \
+ if (mode % 2) \
+ fdin_is_pipe = 1; \
+ else \
+ fdout_is_pipe = 1; \
+ } else { \
+ strncpy(filename, f, sizeof(filename)-1); \
+ filename[sizeof(filename)-1] = 0; \
+ if (mode % 2) { \
+ if (fdin_is_pipe) \
+ fdin_is_pipe = 0; \
+ } else { \
+ if (fdout_is_pipe) \
+ fdout_is_pipe = 0; \
+ } \
+ } \
}
- while ((c = getopt(argc, argv, (mode % 2) ? "ivh?" : "b:isvh?")) != EOF) {
- switch(c) {
- case 'b':
- if (((BLOCKSIZ = (unsigned ) atoi(optarg)) < BLOCKSIZ_MIN) || BLOCKSIZ > BLOCKSIZ_MAX) {
- fprintf(stderr, "error: invalid blocksize: %d\n", BLOCKSIZ);
- fprintf(stderr, " blocksize must be in the range %d <= x <= %d. a value\n", BLOCKSIZ_MIN, BLOCKSIZ_MAX);
- fprintf(stderr, " of %d (default) is suggested, because it fits in an ax25 frame.\n", BLOCKSIZ_DEFAULT);
- exit(1);
- }
- break;
- case 'i':
- do_crc_only = 1;
- break;
- case 's':
- is_stream = 1;
- break;
- case 'v':
- do_version();
- exit(0);
- break;
- case 'h':
- case '?':
- usage((c == 'h'));
- exit(0);
- break;
- }
- }
-
- if (mode == 0) {
- usage(1);
- exit(0);
- }
-
- if (optind < argc) {
- get_filename(argv[optind]);
- optind++;
- }
- if (optind < argc) {
- usage(0);
- exit(1);
- }
-
- if (is_stream && !fdin_is_pipe) {
- fprintf(stderr, "error: -s is only available in a pipe\n");
- exit(1);
- }
-
- if (do_crc_only)
- goto skiped_crc_only_tag_1;
-
- if (mode % 2) {
- if (fdin_is_pipe) {
- fprintf(stderr, "error: error: stdin must be a tty.\n");
- exit(1);
- }
- if (fdout_is_pipe && *filename) {
- fprintf(stderr, "error: filename in a pipe does not make sense.\n");
- exit(1);
- }
- } else {
- if (fdout_is_pipe) {
- fprintf(stderr, "error: stdout must be a tty.\n");
- exit(1);
- }
- if (!fdin_is_pipe && !*filename) {
- fprintf(stderr, "error: no file to send.\n");
- exit(1);
- }
- }
-
- signal(SIGQUIT, signal_handler);
-
- set_tty_flags();
- eol_convention(1);
+ while ((c = getopt(argc, argv, (mode % 2) ? "ivh?" : "b:isvh?")) != EOF) {
+ switch (c) {
+ case 'b':
+ if (((BLOCKSIZ = (unsigned ) atoi(optarg)) < BLOCKSIZ_MIN) || BLOCKSIZ > BLOCKSIZ_MAX) {
+ fprintf(stderr, "error: invalid blocksize: %d\n", BLOCKSIZ);
+ fprintf(stderr, " blocksize must be in the range %d <= x <= %d. a value\n", BLOCKSIZ_MIN, BLOCKSIZ_MAX);
+ fprintf(stderr, " of %d (default) is suggested, because it fits in an ax25 frame.\n", BLOCKSIZ_DEFAULT);
+ exit(1);
+ }
+ break;
+ case 'i':
+ do_crc_only = 1;
+ break;
+ case 's':
+ is_stream = 1;
+ break;
+ case 'v':
+ do_version();
+ exit(0);
+ break;
+ case 'h':
+ case '?':
+ usage((c == 'h'));
+ exit(0);
+ break;
+ }
+ }
+
+ if (mode == 0) {
+ usage(1);
+ exit(0);
+ }
+
+ if (optind < argc) {
+ get_filename(argv[optind]);
+ optind++;
+ }
+ if (optind < argc) {
+ usage(0);
+ exit(1);
+ }
+
+ if (is_stream && !fdin_is_pipe) {
+ fprintf(stderr, "error: -s is only available in a pipe\n");
+ exit(1);
+ }
+
+ if (do_crc_only)
+ goto skiped_crc_only_tag_1;
+
+ if (mode % 2) {
+ if (fdin_is_pipe) {
+ fprintf(stderr, "error: error: stdin must be a tty.\n");
+ exit(1);
+ }
+ if (fdout_is_pipe && *filename) {
+ fprintf(stderr, "error: filename in a pipe does not make sense.\n");
+ exit(1);
+ }
+ } else {
+ if (fdout_is_pipe) {
+ fprintf(stderr, "error: stdout must be a tty.\n");
+ exit(1);
+ }
+ if (!fdin_is_pipe && !*filename) {
+ fprintf(stderr, "error: no file to send.\n");
+ exit(1);
+ }
+ }
+
+ signal(SIGQUIT, signal_handler);
+
+ set_tty_flags();
+ eol_convention(1);
skiped_crc_only_tag_1:
- switch (mode) {
- case RECV_BIN:
- if (do_crc_only)
- ret = bget();
- else
- ret = bput();
- break;
- case SEND_BIN:
- ret = bget();
- break;
- case RECV_YAPP:
- ret = yput();
- break;
- case SEND_YAPP:
- ret = yget();
- break;
- case RECV_DIDADIT:
- ret = rput();
- break;
- case SEND_DIDADIT:
- ret = rget();
- break;
- }
-
- restore_defaults();
- if (*err_msg) {
- fputs(err_msg, stderr);
- }
- exit(ret);
-
- return 0;
+ switch (mode) {
+ case RECV_BIN:
+ if (do_crc_only)
+ ret = bget();
+ else
+ ret = bput();
+ break;
+ case SEND_BIN:
+ ret = bget();
+ break;
+ case RECV_YAPP:
+ ret = yput();
+ break;
+ case SEND_YAPP:
+ ret = yget();
+ break;
+ case RECV_DIDADIT:
+ ret = rput();
+ break;
+ case SEND_DIDADIT:
+ ret = rget();
+ break;
+ }
+
+ restore_defaults();
+ if (*err_msg) {
+ fputs(err_msg, stderr);
+ }
+ exit(ret);
+
+ return 0;
}
-
diff --git a/ax25/axgetput/proto_bin.c b/ax25/axgetput/proto_bin.c
index 004ca5e..5d1bde9 100644
--- a/ax25/axgetput/proto_bin.c
+++ b/ax25/axgetput/proto_bin.c
@@ -11,34 +11,39 @@
#include "util.h"
static int crctab[256];
-static int bittab[8] = { 128,64,32,16,8,4,2,1 };
static int crcbit[8] = {
- 0x9188,0x48c4,0x2462,0x1231,0x8108,0x4084,0x2042,0x1021
+ 0x9188, 0x48c4, 0x2462, 0x1231, 0x8108, 0x4084, 0x2042, 0x1021
};
/*---------------------------------------------------------------------------*/
static int init_crc(void)
{
- int i,j;
-
- for (i = 0; i < 256; i++) {
- crctab[i] = 0;
- for (j = 0; j < 8; j++) {
- if ((bittab[j] & i) != 0) {
- crctab[i] = crctab[i] ^ crcbit[j];
- }
- }
- }
- return 0;
+ int i,j;
+
+ for (i = 0; i < 256; i++) {
+ crctab[i] = 0;
+ for (j = 0; j < 8; j++) {
+ if ((i << j) & 0x80)
+ crctab[i] = crctab[i] ^ crcbit[j];
+ }
+ }
+ return 0;
}
/*---------------------------------------------------------------------------*/
-static int do_crc(char b, int n, unsigned int crc)
+static int do_crc(char b, unsigned int crc)
{
- crc = (crctab[(crc >> 8)] ^ ((crc << 8) | (b & 0xff))) & 0xffff;
- return (crc);
+ return (crctab[(crc >> 8)] ^ ((crc << 8) | (b & 0xff))) & 0xffff;
+}
+
+unsigned int calc_crc(char *buf, int n, unsigned crc)
+{
+ while (--n >= 0)
+ crc = do_crc(*buf++, crc);
+
+ return crc;
}
/*---------------------------------------------------------------------------*/
@@ -46,11 +51,11 @@ static int do_crc(char b, int n, unsigned int crc)
static long parse_sfbin_date_to_unix(const char *s)
{
- unsigned long x;
+ unsigned long x;
- sscanf(s, "%lX", &x);
+ sscanf(s, "%lX", &x);
- return date_dos2unix(((x << 16) >> 16), (x >> 16));
+ return date_dos2unix(((x << 16) >> 16), (x >> 16));
}
/*---------------------------------------------------------------------------*/
@@ -58,450 +63,443 @@ static long parse_sfbin_date_to_unix(const char *s)
static char * unix_to_sfbin_date_string(long gmt)
{
- static char buf[9];
- unsigned short s_time, s_date;
+ static char buf[9];
+ unsigned short s_time, s_date;
- date_unix2dos(((gmt == -1) ? time(0) : gmt), &s_time, &s_date);
- sprintf(buf, "%X", ((s_date << 16) + s_time));
- return buf;
+ date_unix2dos(((gmt == -1) ? time(0) : gmt), &s_time, &s_date);
+ sprintf(buf, "%X", ((s_date << 16) + s_time));
+ return buf;
}
/*---------------------------------------------------------------------------*/
int bput(void)
{
- struct stat statbuf;
- char buf[1024]; /* < signed int */
- char filename_given[PATH_MAX];
- unsigned long len_read_expected = 0L;
- unsigned long len_read_left;
- time_t file_time = 0L;
- unsigned int msg_crc = 0;
- unsigned int crc = 0;
- char *term_line = 0;
- int last_line_had_CR = 0;
- int len_termline = 0;
- int len = 0;
- int fddata = fdout;
- int is_eof;
- int i;
- char *p;
- char *p_buf;
+ struct stat statbuf;
+ char buf[1024]; /* < signed int */
+ char filename_given[PATH_MAX];
+ unsigned long len_read_expected = 0L;
+ unsigned long len_read_left;
+ time_t file_time = 0L;
+ unsigned int msg_crc = 0;
+ unsigned int crc = 0;
+ char *term_line = 0;
+ int last_line_had_CR = 0;
+ int len_termline = 0;
+ int len = 0;
+ int fddata = fdout;
+ int is_eof;
+ int i;
+ char *p;
+ char *p_buf;
#define save_close(x) { \
- if (!fdout_is_pipe) \
- close(x); \
+ if (!fdout_is_pipe) \
+ close(x); \
}
- for (;;) {
- len = my_read(fdin, buf, sizeof(buf), &is_eof, "\r\n");
- if (is_eof || len < 1) {
- sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
- return 1;
- }
- if (buf[len-1] == '\n') {
+ for (;;) {
+ len = my_read(fdin, buf, sizeof(buf), &is_eof, "\r\n");
+ if (is_eof || len < 1) {
+ sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
+ return 1;
+ }
+ if (buf[len-1] == '\n') {
#if 0
- p = "warning: <LF> received. not 8bit clean?\r";
- secure_write(fdout, p, strlen(p));
+ p = "warning: <LF> received. not 8bit clean?\r";
+ secure_write(fdout, p, strlen(p));
#endif
- sprintf(err_msg, "bad EOL: <LF>\n");
- return 1;
- }
- if (IS_BIN_ABORT(buf, len)) {
- sprintf(err_msg, "Aborted by user request\n");
- return 1;
- }
- if (buf[len-1] == '\r' && len > 5 && !memcmp(buf, "#BIN#", 5)) {
- break;
- }
- if (len == sizeof(buf)) {
- sprintf(err_msg, "line to long\n");
- return 1;
- }
- }
- buf[len-1] = 0; /* without trailing \r. and: string termination */
-
- send_on_signal = bin_send_no_on_sig;
-
- /* parse #BIN arguments */
- *filename_given = 0;
-
- p_buf = buf;
- for (i = 0; (p = strsep(&p_buf, "#")); i++) {
- switch(i) {
- case 0:
- case 1:
- break;
- case 2:
- if (*p)
- len_read_expected = (unsigned long ) atol(p);
- break;
- default:
- if (*p == '|') {
- msg_crc = (unsigned int ) atoi(p+1);
- } else if (*p == '$') {
- file_time = parse_sfbin_date_to_unix(p+1);
- } else {
- strncpy(filename_given, p, sizeof(filename_given)-1);
- filename_given[sizeof(filename_given)-1] = 0;
- }
- }
- }
-
- if (!fdout_is_pipe) {
- /* normal mode: store in given filename */
- if (!*filename) {
- p = get_fixed_filename(filename_given, len_read_expected, msg_crc, 1);
- strncpy(filename, p, sizeof(filename)-1);
- filename[sizeof(filename)-1] = 0;
- }
- if (!stat(filename, &statbuf)) {
- /* file exist */
- if (unlink(filename)) {
- sprintf(err_msg, "error: cannot unlink %s (%s)\n", filename, strerror(errno));
- goto abort;
- }
- }
- if ((fddata = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0640)) < 0) {
- sprintf(err_msg, "error: cannot open %s (%s)\n", filename, strerror(errno));
- write(fderr, "\r#NO#\r", 6);
- return 1;
- }
- }
-
- if (!len_read_expected) {
- term_line = "***END\r";
- len_termline = strlen(term_line);
- }
-
- /* say helo */
- send_on_signal = bin_send_abort_on_sig;
- write(fderr, "\r#OK#\r", 6);
-
- len_read_left = len_read_expected;
-
- /* #bin# chechsum initialization */
- init_crc();
-
- for (;;) {
-
- if ((len = my_read(fdin, buf, ((term_line || len_read_left > sizeof(buf)) ? sizeof(buf) : len_read_left), &is_eof, "\r")) < 1) {
- save_close(fddata);
- sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
- goto abort;
- }
- if (!len) {
- save_close(fddata);
- if (!term_line) {
- sprintf(err_msg, "error: unexpected end of file during read: %s\n", strerror(errno));
- return 1;
- }
- return 0;
- }
-
- if (msg_crc) {
- int i;
- for (i = 0; i < len; i++)
- crc = do_crc((int ) buf[i], 1, crc);
- }
-
- if (buf[len-1] == '\r') {
- if (last_line_had_CR) {
- if (IS_BIN_ABORT(buf, len)) {
- /* "\r#ABORT#\r" was sent */
- if (!fdout_is_pipe) {
- close(fddata);
- /* clean up */
- unlink(filename);
- }
- return 1;
+ sprintf(err_msg, "bad EOL: <LF>\n");
+ return 1;
+ }
+ if (IS_BIN_ABORT(buf, len)) {
+ sprintf(err_msg, "Aborted by user request\n");
+ return 1;
+ }
+ if (buf[len-1] == '\r' && len > 5 && !memcmp(buf, "#BIN#", 5)) {
+ break;
+ }
+ if (len == sizeof(buf)) {
+ sprintf(err_msg, "line to long\n");
+ return 1;
+ }
+ }
+ buf[len-1] = 0; /* without trailing \r. and: string termination */
+
+ send_on_signal = bin_send_no_on_sig;
+
+ /* parse #BIN arguments */
+ *filename_given = 0;
+
+ p_buf = buf;
+ for (i = 0; (p = strsep(&p_buf, "#")); i++) {
+ switch (i) {
+ case 0:
+ case 1:
+ break;
+ case 2:
+ if (*p)
+ len_read_expected = (unsigned long ) atol(p);
+ break;
+ default:
+ if (*p == '|') {
+ msg_crc = (unsigned int ) atoi(p+1);
+ } else if (*p == '$') {
+ file_time = parse_sfbin_date_to_unix(p+1);
+ } else {
+ strncpy(filename_given, p, sizeof(filename_given)-1);
+ filename_given[sizeof(filename_given)-1] = 0;
+ }
+ }
+ }
+
+ if (!fdout_is_pipe) {
+ /* normal mode: store in given filename */
+ if (!*filename) {
+ p = get_fixed_filename(filename_given, len_read_expected, msg_crc, 1);
+ strncpy(filename, p, sizeof(filename)-1);
+ filename[sizeof(filename)-1] = 0;
+ }
+ if (!stat(filename, &statbuf)) {
+ /* file exist */
+ if (unlink(filename)) {
+ sprintf(err_msg, "error: cannot unlink %s (%s)\n", filename, strerror(errno));
+ goto abort;
+ }
+ }
+ if ((fddata = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0640)) < 0) {
+ sprintf(err_msg, "error: cannot open %s (%s)\n", filename, strerror(errno));
+ write(fderr, "\r#NO#\r", 6);
+ return 1;
+ }
+ }
+
+ if (!len_read_expected) {
+ term_line = "***END\r";
+ len_termline = strlen(term_line);
+ }
+
+ /* say helo */
+ send_on_signal = bin_send_abort_on_sig;
+ write(fderr, "\r#OK#\r", 6);
+
+ len_read_left = len_read_expected;
+
+ /* #bin# chechsum initialization */
+ init_crc();
+
+ for (;;) {
+
+ if ((len = my_read(fdin, buf, ((term_line || len_read_left > sizeof(buf)) ? sizeof(buf) : len_read_left), &is_eof, "\r")) < 1) {
+ save_close(fddata);
+ sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
+ goto abort;
+ }
+ if (!len) {
+ save_close(fddata);
+ if (!term_line) {
+ sprintf(err_msg, "error: unexpected end of file during read: %s\n", strerror(errno));
+ return 1;
+ }
+ return 0;
+ }
+
+ if (msg_crc)
+ crc = calc_crc(buf, len, 0);
+
+ if (buf[len-1] == '\r') {
+ if (last_line_had_CR) {
+ if (IS_BIN_ABORT(buf, len)) {
+ /* "\r#ABORT#\r" was sent */
+ if (!fdout_is_pipe) {
+ close(fddata);
+ /* clean up */
+ unlink(filename);
+ }
+ return 1;
+ }
+ if (term_line && len == len_termline && !memcmp(buf, term_line, len_termline)) {
+ /* sucessfully read until termination string */
+ break;
+ }
+ }
+ last_line_had_CR = 1;
+ } else {
+ last_line_had_CR = 0;
+ }
+ if (!term_line)
+ len_read_left -= len;
+
+ if (secure_write(fddata, buf, len) == -1) {
+ save_close(fddata);
+ sprintf(err_msg, "error: write failed (%s)\n", strerror(errno));
+ goto abort;
+ }
+
+ /* nothing left? */
+ if (!term_line && len_read_left == 0L)
+ break;
+ if (is_eof) {
+ if (!term_line && len_read_left) {
+ save_close(fddata);
+ goto abort;
+ }
+ break;
+ }
}
- if (term_line && len == len_termline && !memcmp(buf, term_line, len_termline)) {
- /* sucessfully read until termination string */
- break;
+ if (crc != msg_crc) {
+ sprintf(err_msg, "Invalid crc: computed %d, expected %d.\n", crc, msg_crc);
+ /* don't unlink */
+ save_close(fddata);
+ return 1;
}
- }
- last_line_had_CR = 1;
- } else {
- last_line_had_CR = 0;
- }
- if (!term_line)
- len_read_left -= len;
-
- if (secure_write(fddata, buf, len) == -1) {
- save_close(fddata);
- sprintf(err_msg, "error: write failed (%s)\n", strerror(errno));
- goto abort;
- }
-
- /* nothing left? */
- if (!term_line && len_read_left == 0L)
- break;
- if (is_eof) {
- if (!term_line && len_read_left) {
- save_close(fddata);
- goto abort;
- }
- break;
- }
- }
- if (crc != msg_crc) {
- sprintf(err_msg, "Invalid crc: computed %d, expected %d.\n", crc, msg_crc);
- /* don't unlink */
- save_close(fddata);
- return 1;
- }
- if (!fdout_is_pipe) {
- close(fddata);
- if (file_time != 0L) {
- struct utimbuf utb;
- utb.modtime = file_time;
- utb.actime = time(0);
- utime(filename, &utb);
- }
- }
-
- send_on_signal = 0;
- return 0;
+ if (!fdout_is_pipe) {
+ close(fddata);
+ if (file_time != 0L) {
+ struct utimbuf utb;
+ utb.modtime = file_time;
+ utb.actime = time(0);
+ utime(filename, &utb);
+ }
+ }
+
+ send_on_signal = 0;
+ return 0;
abort:
- sleep(1);
- write(fderr, "\r#ABORT#\r", 9);
- return 1;
+ sleep(1);
+ write(fderr, "\r#ABORT#\r", 9);
+ return 1;
#undef save_close
}
/*---------------------------------------------------------------------------*/
int bget(void) {
- struct strlist {
- struct strlist *next;
- size_t len;
- char data[1]; /* actually a the address of char * pointer */
- };
-
- struct strlist *stored_file = 0;
- struct strlist *sl_tail = 0;
- struct strlist *sl;
- struct timeval timeout;
- struct stat statbuf;
-
- unsigned int crc = 0;
-
- char buf[1024];
- fd_set readfds;
- int fddata = fdin;
- int len;
- unsigned long file_size = 0;
- unsigned long len_remains;
- int is_eof;
- time_t file_time = 0L;
+ struct strlist {
+ struct strlist *next;
+ size_t len;
+ char data[1]; /* actually a the address of char * pointer */
+ };
+
+ struct strlist *stored_file = 0;
+ struct strlist *sl_tail = 0;
+ struct strlist *sl;
+ struct timeval timeout;
+ struct stat statbuf;
+
+ unsigned int crc = 0;
+
+ char buf[1024];
+ fd_set readfds;
+ int fddata = fdin;
+ int len;
+ unsigned long file_size = 0;
+ unsigned long len_remains;
+ int is_eof;
+ time_t file_time = 0L;
#define save_close(x) { \
- if (!fdin_is_pipe) \
- close(x); \
+ if (!fdin_is_pipe) \
+ close(x); \
}
#define store_line(s, len) { \
- if (!(sl = (struct strlist *) malloc(sizeof(struct strlist *) + sizeof(size_t) + len))) \
- return 1; \
+ if (!(sl = (struct strlist *) malloc(sizeof(struct strlist *) + sizeof(size_t) + len))) \
+ return 1; \
sl->next = 0; \
sl->len = len; \
memcpy(sl->data, s, len); \
if (!stored_file) { \
- stored_file = sl; \
+ stored_file = sl; \
} else { \
- sl_tail->next = sl; \
+ sl_tail->next = sl; \
} \
sl_tail = sl; \
}
- if (BLOCKSIZ < 1 || BLOCKSIZ > sizeof(buf))
- BLOCKSIZ = BLOCKSIZ_DEFAULT;
-
- init_crc();
-
- if (!fdin_is_pipe && *filename) {
- if ((fddata = open(filename, O_RDONLY)) == -1) {
- sprintf(err_msg, "error: cannot open %s (%s)\n", filename, strerror(errno));
- return 1;
- }
- if (!fstat(fddata, &statbuf))
- file_time = statbuf.st_mtime;
- else
- file_time = time(0);
-
- /* compute crc */
- while ((len = read(fddata, buf, BLOCKSIZ)) > 0) {
- int i;
- for (i = 0; i < len; i++)
- crc = do_crc((int ) buf[i], 1, crc);
- file_size += len;
- }
- if (len < 0) {
- sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
- close(fddata);
- return 1;
- }
- /* rewind */
- if (lseek(fddata, 0L, SEEK_SET) != 0L) {
- sprintf(err_msg, "error: file io failed on lseek() (%s)\n", strerror(errno));
- close(fddata);
- return 1;
- }
- sprintf(buf, "\r#BIN#%ld#|%d#$%s#%s\r", file_size, crc, unix_to_sfbin_date_string(file_time), get_fixed_filename(filename, file_size, crc, 1));
- } else {
- file_time = time(0);
- if (!is_stream || do_crc_only) {
- sprintf(err_msg, "error: not enough memory\n");
- while ((len = read(fddata, buf, sizeof(buf))) > 0) {
- int i;
- for (i = 0; i < len; i++)
- crc = do_crc((int ) buf[i], 1, crc);
- file_size += len;
- if (!do_crc_only)
- store_line(buf, len);
- }
- if (len < 0) {
- sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
- close(fddata);
- return 1;
- }
- *err_msg = 0;
- sprintf(buf, "\r#BIN#%ld#|%d#$%s#%s\r", file_size, crc, unix_to_sfbin_date_string(file_time), get_fixed_filename(filename, file_size, crc, 1));
- } else {
- sprintf(buf, "\r#BIN###$%s#%s\r", unix_to_sfbin_date_string(file_time), get_fixed_filename(filename, 0, 0, 1));
- }
- /*
- * hack: check for #ABORT# from fdout (fd 1), because fddata (fd 0) is
- * our pipe we read the data from, which we actually tx.
- * believe me, it does work.
- */
- fdin = fdout;
- }
-
- if (do_crc_only) {
- printf("File information for %s:\n", get_fixed_filename(filename, file_size, crc, 1));
- printf(" size %ld bytes, crc %d, date %s (%ld)\n", file_size, crc, unix_to_sfbin_date_string(file_time), file_time);
- return 0;
- }
-
- send_on_signal = bin_send_abort_on_sig;
- if (secure_write(fdout, buf, strlen(buf)) == -1) {
- sprintf(err_msg, "error: write failed (%s)\n", strerror(errno));
- save_close(fddata);
- return 1;
- }
-
- /* wait for answer */
- for (;;) {
- /*
- * make sure we do not read from a pipe. fdout is also
- * assigned to the tty
- */
- len = my_read(fdout, buf, sizeof(buf), &is_eof, "\r\n");
- if (is_eof || len < 1) {
- sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
- save_close(fddata);
- return 1;
- }
- if (buf[len-1] == '\n') {
+ if (BLOCKSIZ < 1 || BLOCKSIZ > sizeof(buf))
+ BLOCKSIZ = BLOCKSIZ_DEFAULT;
+
+ init_crc();
+
+ if (!fdin_is_pipe && *filename) {
+ if ((fddata = open(filename, O_RDONLY)) == -1) {
+ sprintf(err_msg, "error: cannot open %s (%s)\n", filename, strerror(errno));
+ return 1;
+ }
+ if (!fstat(fddata, &statbuf))
+ file_time = statbuf.st_mtime;
+ else
+ file_time = time(0);
+
+ /* compute crc */
+ while ((len = read(fddata, buf, BLOCKSIZ)) > 0) {
+ crc = calc_crc(buf, len, 0);
+ file_size += len;
+ }
+ if (len < 0) {
+ sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
+ close(fddata);
+ return 1;
+ }
+ /* rewind */
+ if (lseek(fddata, 0L, SEEK_SET) != 0L) {
+ sprintf(err_msg, "error: file io failed on lseek() (%s)\n", strerror(errno));
+ close(fddata);
+ return 1;
+ }
+ sprintf(buf, "\r#BIN#%ld#|%d#$%s#%s\r", file_size, crc, unix_to_sfbin_date_string(file_time), get_fixed_filename(filename, file_size, crc, 1));
+ } else {
+ file_time = time(0);
+ if (!is_stream || do_crc_only) {
+ sprintf(err_msg, "error: not enough memory\n");
+ while ((len = read(fddata, buf, sizeof(buf))) > 0) {
+ crc = calc_crc(buf, len, 0);
+ file_size += len;
+ if (!do_crc_only)
+ store_line(buf, len);
+ }
+ if (len < 0) {
+ sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
+ close(fddata);
+ return 1;
+ }
+ *err_msg = 0;
+ sprintf(buf, "\r#BIN#%ld#|%d#$%s#%s\r", file_size, crc, unix_to_sfbin_date_string(file_time), get_fixed_filename(filename, file_size, crc, 1));
+ } else {
+ sprintf(buf, "\r#BIN###$%s#%s\r", unix_to_sfbin_date_string(file_time), get_fixed_filename(filename, 0, 0, 1));
+ }
+ /*
+ * hack: check for #ABORT# from fdout (fd 1), because fddata (fd 0) is
+ * our pipe we read the data from, which we actually tx.
+ * believe me, it does work.
+ */
+ fdin = fdout;
+ }
+
+ if (do_crc_only) {
+ printf("File information for %s:\n", get_fixed_filename(filename, file_size, crc, 1));
+ printf(" size %ld bytes, crc %d, date %s (%ld)\n", file_size, crc, unix_to_sfbin_date_string(file_time), file_time);
+ return 0;
+ }
+
+ send_on_signal = bin_send_abort_on_sig;
+ if (secure_write(fdout, buf, strlen(buf)) == -1) {
+ sprintf(err_msg, "error: write failed (%s)\n", strerror(errno));
+ save_close(fddata);
+ return 1;
+ }
+
+ /* wait for answer */
+ for (;;) {
+ /*
+ * make sure we do not read from a pipe. fdout is also
+ * assigned to the tty
+ */
+ len = my_read(fdout, buf, sizeof(buf), &is_eof, "\r\n");
+ if (is_eof || len < 1) {
+ sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
+ save_close(fddata);
+ return 1;
+ }
+ if (buf[len-1] == '\n') {
#if 0
- char *p = "warning: <LF> received. not 8bit clean?\r";
- secure_write(fdout, p, strlen(p));
+ char *p = "warning: <LF> received. not 8bit clean?\r";
+ secure_write(fdout, p, strlen(p));
#endif
- sprintf(err_msg, "bad EOL: <LF>\n");
- goto abort;
- } else if (buf[len-1] != '\r') {
- sprintf(err_msg, "line to long\n");
- continue;
- }
- if (IS_BIN_OK(buf, len))
- break;
- if (IS_BIN_NO(buf, len)) {
- save_close(fddata);
- return 0;
- }
- if (IS_BIN_ABORT(buf, len)) {
- sprintf(err_msg, "Aborted by user request\n");
- save_close(fddata);
- return 1;
- }
- }
-
- len_remains = file_size;
- timeout.tv_sec = 0;
- timeout.tv_usec = 0;
-
- for (;;) {
- char *p_buf;
-
- /* check for user \r#ABORT#\r on tty stream */
- FD_ZERO(&readfds);
- FD_SET(fdin, &readfds);
- if (select(fdin+1, &readfds, 0, 0, &timeout) && FD_ISSET(fdin, &readfds)) {
- if ((len = read(fdin, buf, sizeof(buf))) < 0) {
- sprintf(err_msg, "read from tty failed (%s)\n", strerror(errno));
- save_close(fddata);
- goto abort;
- }
- if (IS_BIN_ABORT(buf, len)) {
- sprintf(err_msg, "Aborted by user request\n");
- save_close(fddata);
- return 1;
- }
- }
- /* read data */
- if (!fdin_is_pipe || is_stream) {
- p_buf = buf;
- if ((len = my_read(fddata, buf, ((len_remains > BLOCKSIZ || is_stream) ? BLOCKSIZ : len_remains), &is_eof, 0)) < 1) {
- save_close(fddata);
- if (len < 0) {
- sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
- goto abort;
- }
- break;
- }
- len_remains -= len;
- } else {
- p_buf = stored_file->data;
- len = stored_file->len;
- }
- /* write to client */
- if (secure_write(fdout, p_buf, len) == -1) {
- sprintf(err_msg, "error: write failed (%s)\n", strerror(errno));
- save_close(fddata);
- goto abort;
- }
- if (fdin_is_pipe && !is_stream) {
- sl = stored_file;
- if (!(stored_file = stored_file->next))
- is_eof = 1;
- free(sl);
- }
- if (!fdin_is_pipe && !len_remains) {
- if (read(fddata, buf, 1) == 1) {
- sprintf(err_msg, "Warning: file has grown in the meantime\n");
- }
- is_eof = 1;
- break;
- }
- /*
- * need this because my_read may returned lenth != 0 (data to be written)
- * but also has detected EOF.
- */
- if (is_eof)
- break;
- }
-
- sleep(10);
-
- return 0;
+ sprintf(err_msg, "bad EOL: <LF>\n");
+ goto abort;
+ } else if (buf[len-1] != '\r') {
+ sprintf(err_msg, "line to long\n");
+ continue;
+ }
+ if (IS_BIN_OK(buf, len))
+ break;
+ if (IS_BIN_NO(buf, len)) {
+ save_close(fddata);
+ return 0;
+ }
+ if (IS_BIN_ABORT(buf, len)) {
+ sprintf(err_msg, "Aborted by user request\n");
+ save_close(fddata);
+ return 1;
+ }
+ }
+
+ len_remains = file_size;
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+
+ for (;;) {
+ char *p_buf;
+
+ /* check for user \r#ABORT#\r on tty stream */
+ FD_ZERO(&readfds);
+ FD_SET(fdin, &readfds);
+ if (select(fdin+1, &readfds, 0, 0, &timeout) && FD_ISSET(fdin, &readfds)) {
+ if ((len = read(fdin, buf, sizeof(buf))) < 0) {
+ sprintf(err_msg, "read from tty failed (%s)\n", strerror(errno));
+ save_close(fddata);
+ goto abort;
+ }
+ if (IS_BIN_ABORT(buf, len)) {
+ sprintf(err_msg, "Aborted by user request\n");
+ save_close(fddata);
+ return 1;
+ }
+ }
+ /* read data */
+ if (!fdin_is_pipe || is_stream) {
+ p_buf = buf;
+ if ((len = my_read(fddata, buf, ((len_remains > BLOCKSIZ || is_stream) ? BLOCKSIZ : len_remains), &is_eof, 0)) < 1) {
+ save_close(fddata);
+ if (len < 0) {
+ sprintf(err_msg, "error: read failed (%s)\n", strerror(errno));
+ goto abort;
+ }
+ break;
+ }
+ len_remains -= len;
+ } else {
+ p_buf = stored_file->data;
+ len = stored_file->len;
+ }
+ /* write to client */
+ if (secure_write(fdout, p_buf, len) == -1) {
+ sprintf(err_msg, "error: write failed (%s)\n", strerror(errno));
+ save_close(fddata);
+ goto abort;
+ }
+ if (fdin_is_pipe && !is_stream) {
+ sl = stored_file;
+ if (!(stored_file = stored_file->next))
+ is_eof = 1;
+ free(sl);
+ }
+ if (!fdin_is_pipe && !len_remains) {
+ if (read(fddata, buf, 1) == 1) {
+ sprintf(err_msg, "Warning: file has grown in the meantime\n");
+ }
+ is_eof = 1;
+ break;
+ }
+ /*
+ * need this because my_read may returned lenth != 0 (data to be written)
+ * but also has detected EOF.
+ */
+ if (is_eof)
+ break;
+ }
+
+ sleep(10);
+
+ return 0;
abort:
- sleep(1);
- write(fderr, "\r#ABORT#\r", 9);
- return 1;
+ sleep(1);
+ write(fderr, "\r#ABORT#\r", 9);
+ return 1;
#undef save_close
}
diff --git a/ax25/axgetput/util.c b/ax25/axgetput/util.c
index 4aff6a0..5501035 100644
--- a/ax25/axgetput/util.c
+++ b/ax25/axgetput/util.c
@@ -54,15 +54,15 @@ int my_read(int fd, char *s, int len_max, int *eof, char *p_break)
if ((len = read(fd, s_curr, (p_break ? 1 : len_max))) < 1) {
if (len == -1 && errno == EAGAIN) {
- sleep(10);
- continue;
+ sleep(10);
+ continue;
}
*eof = 1;
/*
* len = 0: normal eof. if we're looking for a string, return -1 since
* we have'nt found
*/
- return (len == 0 && p_break ? -1 : (len_got ? len_got : len));
+ return len == 0 && p_break ? -1 : (len_got ? len_got : len);
}
len_got += len;
@@ -79,7 +79,7 @@ int my_read(int fd, char *s, int len_max, int *eof, char *p_break)
return len_got;
}
-
+
/*---------------------------------------------------------------------------*/
int secure_write(int fd, char *s, int len_write) {
@@ -89,8 +89,8 @@ int secure_write(int fd, char *s, int len_write) {
int len;
if ((len = write(fd, s, len_write_left_curr)) < 0) {
if (len == -1 && errno == EAGAIN) {
- sleep(10);
- continue;
+ sleep(10);
+ continue;
}
return -1;
}
@@ -162,22 +162,22 @@ char *get_fixed_filename(char *line, long size, unsigned int msg_crc, int genera
/* Linear day numbers of the respective 1sts in non-leap years. */
static int day_n[] = { 0,31,59,90,120,151,181,212,243,273,304,334,0,0,0,0 };
- /* JanFebMarApr May Jun Jul Aug Sep Oct Nov Dec */
+ /* JanFebMarApr May Jun Jul Aug Sep Oct Nov Dec */
/*---------------------------------------------------------------------------*/
long date_dos2unix(unsigned short time,unsigned short date)
{
- int month,year;
- long secs;
-
- month = ((date >> 5) & 15)-1;
- year = date >> 9;
- secs = (time & 31)*2+60*((time >> 5) & 63)+(time >> 11)*3600+86400*
- ((date & 31)-1+day_n[month]+(year/4)+year*365-((year & 3) == 0 &&
- month < 2 ? 1 : 0)+3653);
- /* days since 1.1.70 plus 80's leap day */
- return secs;
+ int month,year;
+ long secs;
+
+ month = ((date >> 5) & 15)-1;
+ year = date >> 9;
+ secs = (time & 31)*2+60*((time >> 5) & 63)+(time >> 11)*3600+86400*
+ ((date & 31)-1+day_n[month]+(year/4)+year*365-((year & 3) == 0 &&
+ month < 2 ? 1 : 0)+3653);
+ /* days since 1.1.70 plus 80's leap day */
+ return secs;
}
/*---------------------------------------------------------------------------*/
@@ -186,23 +186,22 @@ long date_dos2unix(unsigned short time,unsigned short date)
void date_unix2dos(int unix_date,unsigned short *time, unsigned short *date)
{
- int day,year,nl_day,month;
-
- *time = (unix_date % 60)/2+(((unix_date/60) % 60) << 5)+
- (((unix_date/3600) % 24) << 11);
- day = unix_date/86400-3652;
- year = day/365;
- if ((year+3)/4+365*year > day) year--;
- day -= (year+3)/4+365*year;
- if (day == 59 && !(year & 3)) {
- nl_day = day;
- month = 2;
- }
- else {
- nl_day = (year & 3) || day <= 59 ? day : day-1;
- for (month = 0; month < 12; month++)
- if (day_n[month] > nl_day) break;
- }
- *date = nl_day-day_n[month-1]+1+(month << 5)+(year << 9);
+ int day,year,nl_day,month;
+
+ *time = (unix_date % 60)/2+(((unix_date/60) % 60) << 5)+
+ (((unix_date/3600) % 24) << 11);
+ day = unix_date/86400-3652;
+ year = day/365;
+ if ((year+3)/4+365*year > day) year--;
+ day -= (year+3)/4+365*year;
+ if (day == 59 && !(year & 3)) {
+ nl_day = day;
+ month = 2;
+ }
+ else {
+ nl_day = (year & 3) || day <= 59 ? day : day-1;
+ for (month = 0; month < 12; month++)
+ if (day_n[month] > nl_day) break;
+ }
+ *date = nl_day-day_n[month-1]+1+(month << 5)+(year << 9);
}
-
diff --git a/ax25/axparms.8 b/ax25/axparms.8
index 9989be8..3187158 100644
--- a/ax25/axparms.8
+++ b/ax25/axparms.8
@@ -70,12 +70,12 @@ The formats of this option are:
.fi
.LP
Routes added via this command will not be removed from the internal routing
-table when they are \(lqold\(rq as normal entries are. The
+table when they are \(lqold\(rq as normal entries are. The
.B --ipmode
option sets mode vc or mode datagram for this destination.
.LP
-If the <callsign> argument is set to \(lqdefault\(rq then this will set the
-default route for all outgoing AX.25 connections which will be used when there
+If the <callsign> argument is set to \(lqdefault\(rq then this will set the
+default route for all outgoing AX.25 connections which will be used when there
is no specific route to the required destination.
.SH "--setcall Argument"
.LP
@@ -92,7 +92,7 @@ ax0, ax1, .., sp0, .., bpq0, ... etc..
The change is permanent as long as the interface exists, or another \(lqaxparms
--setcall\(rq is issued.
.LP
-The interface has to exist already in order to use this option; it
+The interface has to exist already in order to use this option; it
may be in state UP or DOWN.
.SH "--version Argument"
.LP
diff --git a/ax25/axparms.c b/ax25/axparms.c
index daac7d4..71724f7 100644
--- a/ax25/axparms.c
+++ b/ax25/axparms.c
@@ -79,17 +79,17 @@ int routes(int s, int argc, char *argv[], ax25_address *callsign)
return 1;
}
switch (*argv[i]) {
- case 'd':
- case 'D':
- ip_mode = 'D';
- break;
- case 'v':
- case 'V':
- ip_mode = 'V';
- break;
- default:
- ip_mode = ' ';
- break;
+ case 'd':
+ case 'D':
+ ip_mode = 'D';
+ break;
+ case 'v':
+ case 'V':
+ ip_mode = 'V';
+ break;
+ default:
+ ip_mode = ' ';
+ break;
}
} else {
if (ax25_aton_entry(argv[i], (char *)&ax25_route.digi_addr[j]) == -1)
@@ -103,18 +103,18 @@ int routes(int s, int argc, char *argv[], ax25_address *callsign)
perror("axparms: SIOCADDRT");
return 1;
}
-
+
ax25_opt.port_addr = *callsign;
ax25_opt.dest_addr = ax25_route.dest_addr;
ax25_opt.cmd = AX25_SET_RT_IPMODE;
ax25_opt.arg = ip_mode;
-
+
if (ioctl(s, SIOCAX25OPTRT, &ax25_opt) != 0) {
perror("axparms: SIOCAX25OPTRT");
return 1;
}
}
-
+
if (strcmp(argv[2], "del") == 0) {
ax25_route.port_addr = *callsign;
ax25_route.digi_count = 0;
@@ -150,14 +150,14 @@ int setifcall(int s, char *ifn, char *name)
{
char call[7];
struct ifreq ifr;
-
+
if (ax25_aton_entry(name, call) == -1)
return 1;
strcpy(ifr.ifr_name, ifn);
memcpy(ifr.ifr_hwaddr.sa_data, call, 7);
ifr.ifr_hwaddr.sa_family = AF_AX25;
-
+
if (ioctl(s, SIOCSIFHWADDR, &ifr) != 0) {
perror("axparms: SIOCSIFHWADDR");
return 1;
@@ -174,7 +174,7 @@ int associate(int s, int argc, char *argv[])
int opt;
FILE *fp;
-
+
if (strcmp(argv[2], "show") == 0) {
if (argc < 3) {
usageassoc();
@@ -239,7 +239,7 @@ int associate(int s, int argc, char *argv[])
usageassoc();
exit(1);
}
-
+
if (ax25_aton_entry(argv[2], (char *)&sax25.sax25_call) == -1) {
fprintf(stderr, "axparms: associate: invalid callsign %s\n", argv[2]);
return 1;
@@ -260,7 +260,7 @@ int associate(int s, int argc, char *argv[])
}
sax25.sax25_uid = pw->pw_uid;
-
+
if (ioctl(s, SIOCAX25ADDUID, &sax25) == -1) {
perror("axparms: SIOCAX25ADDUID");
return 1;
@@ -319,7 +319,7 @@ int forward(int s, int argc, char *argv[])
return 1;
}
#else
- fprintf(stderr, "axparms: Not compiled in with forwarding option.\n");
+ fprintf(stderr, "axparms: Not compiled in with forwarding option.\n");
#endif /* HAVE_AX25_FWD_STRUCT */
return 0;
@@ -383,7 +383,7 @@ int main(int argc, char **argv)
usageroute();
return 1;
}
-
+
if (strcmp(argv[2], "add") != 0 && strcmp(argv[2], "del") != 0 && strcmp(argv[2], "list") != 0) {
usageroute();
return 1;
@@ -393,7 +393,7 @@ int main(int argc, char **argv)
usageroute();
return 1;
}
-
+
if (ax25_config_load_ports() == 0) {
fprintf(stderr, "axparms: no AX.25 port data configured\n");
return 1;
@@ -415,7 +415,7 @@ int main(int argc, char **argv)
n = routes(s, argc, argv, &callsign);
close(s);
-
+
return n;
}
@@ -424,7 +424,7 @@ int main(int argc, char **argv)
usagesetcall();
return 1;
}
-
+
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
perror("axparms: socket");
return 1;
diff --git a/ax25/axspawn.8 b/ax25/axspawn.8
index db34d23..672f680 100644
--- a/ax25/axspawn.8
+++ b/ax25/axspawn.8
@@ -40,7 +40,7 @@ and
standards.
axspawn searches in /etc/ax25/bcpasswd (first) and ~user/.bcpasswd (second)
for a match of the required authentication mechanism and password.
-md5 and baycom passwords may differ. md5 passwords gain over baycom passwords.
+md5 and baycom passwords may differ. md5 passwords gain over baycom passwords.
Note: you could "lock" special "friends" out by specifying an empty password
in /etc/ax25/bcpasswd (line "n0call:md5:"). -> md5 Passwords are enforced. But
@@ -48,7 +48,7 @@ the length is shorter than the minimum (len 8 for md5, len 20 for baycom);
user's password file is not searched because in /etc/ax25/bcpasswd its already
found..
-Syntax and caveeats for /etc/ax25/bcpasswd:
+Syntax and caveeats for /etc/ax25/bcpasswd:
- Has to be a regular file (no symlink). Not world-readable/writable.
- Example lines:
# Thomas
@@ -82,7 +82,7 @@ properly.
.TP 5
.B -c, --changeuser
Allow connecting ax25 users to change their username for login. They'll be
-asked for their real login name.
+asked for their real login name.
.TP 5
.B -e, --embedded
Special treatment for axspawn on non-standard conform embedded devices.
diff --git a/ax25/axspawn.c b/ax25/axspawn.c
index 6092b77..4b1e410 100644
--- a/ax25/axspawn.c
+++ b/ax25/axspawn.c
@@ -4,18 +4,18 @@
* Copyright (c) 1996 Joerg Reuter DL1BKE (jreuter@poboxes.com)
*
* This program is a hack.
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * It might even kill your cat... ;-)
+ * It might even kill your cat... ;-)
*
* Status: alpha (still...)
*
@@ -28,19 +28,19 @@
* default * * * * * 1 root /usr/local/sbin/axspawn axspawn --wait
*
* The program will check if the peer is an AX.25 socket, the
- * callsign is a valid amateur radio callsign, strip the SSID,
+ * callsign is a valid amateur radio callsign, strip the SSID,
* check if UID/GID are valid, allow a password-less login if the
* password-entry in /etc/passwd is "+" or empty; in every other case
* login will prompt for a password.
*
- * Still on my TODO list: a TheNet compatible or MD5 based
+ * Still on my TODO list: a TheNet compatible or MD5 based
* authentication scheme... Won't help you if you changed the "+"-entry
- * in /etc/passwd to a valid passord and login with telnet, though.
+ * in /etc/passwd to a valid passord and login with telnet, though.
* A better solution could be a small program called from .profile.
*
* Axspawn can create user accounts automatically. You may specify
* the user shell, first and maximum user id, group ID in the config
- * file and (unlike WAMPES) create a file "/usr/local/etc/ax25.profile"
+ * file and (unlike WAMPES) create a file "/usr/local/etc/ax25.profile"
* which will be copied to ~/.profile.
*
* This is an example for the config file:
@@ -126,7 +126,7 @@
* shorter than 6 characters (without SSID). There must be at least
* one digit, and max. two digits within the call. The SSID must
* be within the range of 0 and 15. Please drop me a note if you
- * know a valid Amateur Radio (sic!) callsign that does not fit this
+ * know a valid Amateur Radio (sic!) callsign that does not fit this
* pattern _and_ can be represented correctly in AX.25.
*
* It uses the forkpty from libbsd.a (found after analyzing logind)
@@ -219,222 +219,222 @@ struct huffdecodtab {
/* huffman encoding table */
static struct huffencodtab huffencodtab[] = {
-{0xab2c,15},{0xaa84,15},{0x9fc4,15},{0xab3c,15},
-{0xab1c,15},{0xaafc,15},{0xaaec,15},{0xaad4,15},
-{0xaab4,15},{0xf340,10},{0xaaa4,15},{0x7d64,15},
-{0xaadc,15},{0xf400, 7},{0xaa94,15},{0x9ff4,15},
-{0x9fd4,15},{0x7d74,15},{0xab44,15},{0xab34,15},
-{0xab24,15},{0xab14,15},{0xab04,15},{0xaaf4,15},
-{0xaae4,15},{0xab60,14},{0xab0c,15},{0xaacc,15},
-{0xaabc,15},{0xaaac,15},{0xaa9c,15},{0xaa8c,15},
-{0xc000, 3},{0x3a80, 9},{0xabc0,10},{0x0060,11},
-{0x7d40,12},{0xab5c,14},{0x0000,12},{0xab58,14},
-{0x7c00, 9},{0x3c80, 9},{0x7d00,11},{0x0010,12},
-{0x1200, 7},{0x7a00, 7},{0xb800, 6},{0x3200, 7},
-{0x2200, 7},{0xf600, 8},{0x3d00, 8},{0x9e00, 9},
-{0xbd80, 9},{0x7c80, 9},{0x0080, 9},{0xaa00, 9},
-{0xbd00, 9},{0x9f00, 9},{0x0300, 8},{0xab78,13},
-{0xab68,13},{0x3c00, 9},{0x3000, 9},{0x0020,11},
-{0x7d50,12},{0x3800, 7},{0x7800, 7},{0x9c00, 7},
-{0xfe00, 7},{0x2400, 6},{0xbc00, 8},{0x0200, 8},
-{0x0100, 8},{0xf100, 8},{0x0040,11},{0x3100, 8},
-{0xf200, 8},{0x3400, 7},{0x1c00, 7},{0x1e00, 7},
-{0xbe00, 7},{0xaba0,11},{0x3e00, 7},{0x1400, 6},
-{0x3600, 7},{0xf380, 9},{0xf080, 9},{0x2000, 8},
-{0xfc00, 8},{0x9f80,10},{0x9e80, 9},{0xab90,12},
-{0x3b80, 9},{0xab80,12},{0xab54,14},{0x3a50,13},
-{0xab50,14},{0xa000, 5},{0x1800, 6},{0x9800, 6},
-{0x7000, 5},{0x4000, 3},{0x0400, 6},{0xac00, 6},
-{0xf800, 6},{0x6000, 4},{0x3a00,10},{0xfd00, 8},
-{0x2800, 5},{0xb000, 6},{0x8000, 4},{0xb400, 6},
-{0x1000, 7},{0x7d20,12},{0xe000, 5},{0x9000, 5},
-{0xe800, 5},{0x0800, 5},{0xf700, 8},{0xa800, 7},
-{0x7d80, 9},{0xf300,10},{0x7e00, 7},{0xab48,14},
-{0x3a48,13},{0xab4c,14},{0x3a60,12},{0x9ffc,15},
-{0x9fec,15},{0x2100, 8},{0x9fdc,15},{0x9fcc,15},
-{0xf000, 9},{0x7d7c,15},{0x7d6c,15},{0x3a40,14},
-{0xab40,15},{0xab38,15},{0xab30,15},{0xab28,15},
-{0xab20,15},{0xab18,15},{0xab70,13},{0xab10,15},
-{0xab08,15},{0xab00,15},{0xaaf8,15},{0xaaf0,15},
-{0x3b00, 9},{0xaae8,15},{0xaae0,15},{0xaad8,15},
-{0xaad0,15},{0xab64,14},{0x7d30,12},{0xaac8,15},
-{0xaac0,15},{0xaab8,15},{0xaab0,15},{0xaaa8,15},
-{0xaaa0,15},{0xaa98,15},{0xaa90,15},{0xaa88,15},
-{0xaa80,15},{0x9ff8,15},{0x9ff0,15},{0x9fe8,15},
-{0x9fe0,15},{0x9fd8,15},{0x9fd0,15},{0x9fc8,15},
-{0x9fc0,15},{0x7d78,15},{0x7d70,15},{0x3a58,13},
-{0x7d68,15},{0x7d60,15},{0xab46,15},{0xab42,15},
-{0xab3e,15},{0xab3a,15},{0xab36,15},{0xab32,15},
-{0xab2e,15},{0xab2a,15},{0xab26,15},{0xab22,15},
-{0xab1e,15},{0xab1a,15},{0xab16,15},{0xab12,15},
-{0xab0e,15},{0xab0a,15},{0xab06,15},{0xab02,15},
-{0xaafe,15},{0xaafa,15},{0xaaf6,15},{0xaaf2,15},
-{0xaaee,15},{0xaaea,15},{0xaae6,15},{0xaae2,15},
-{0xaade,15},{0xaada,15},{0xaad6,15},{0xaad2,15},
-{0xaace,15},{0xaaca,15},{0xaac6,15},{0xaac2,15},
-{0xaabe,15},{0xaaba,15},{0xaab6,15},{0xaab2,15},
-{0xaaae,15},{0xaaaa,15},{0xaaa6,15},{0xaaa2,15},
-{0xaa9e,15},{0x3a70,12},{0xaa9a,15},{0xaa96,15},
-{0xaa92,15},{0x3080, 9},{0xaa8e,15},{0xaa8a,15},
-{0xaa86,15},{0xaa82,15},{0x9ffe,15},{0x9ffa,15},
-{0x9ff6,15},{0x9ff2,15},{0x9fee,15},{0x9fea,15},
-{0x9fe6,15},{0x9fe2,15},{0x9fde,15},{0x9fda,15},
-{0x9fd6,15},{0x9fd2,15},{0x9fce,15},{0x9fca,15},
-{0x9fc6,15},{0x9fc2,15},{0x7d7e,15},{0x7d7a,15},
-{0x7d76,15},{0x7d72,15},{0x7d6e,15},{0x7d6a,15},
-{0x7d66,15},{0x7d62,15},{0x3a46,15},{0x3a44,15}
+ {0xab2c, 15}, {0xaa84, 15}, {0x9fc4, 15}, {0xab3c, 15},
+ {0xab1c, 15}, {0xaafc, 15}, {0xaaec, 15}, {0xaad4, 15},
+ {0xaab4, 15}, {0xf340, 10}, {0xaaa4, 15}, {0x7d64, 15},
+ {0xaadc, 15}, {0xf400, 7}, {0xaa94, 15}, {0x9ff4, 15},
+ {0x9fd4, 15}, {0x7d74, 15}, {0xab44, 15}, {0xab34, 15},
+ {0xab24, 15}, {0xab14, 15}, {0xab04, 15}, {0xaaf4, 15},
+ {0xaae4, 15}, {0xab60, 14}, {0xab0c, 15}, {0xaacc, 15},
+ {0xaabc, 15}, {0xaaac, 15}, {0xaa9c, 15}, {0xaa8c, 15},
+ {0xc000, 3}, {0x3a80, 9}, {0xabc0, 10}, {0x0060, 11},
+ {0x7d40, 12}, {0xab5c, 14}, {0x0000, 12}, {0xab58, 14},
+ {0x7c00, 9}, {0x3c80, 9}, {0x7d00, 11}, {0x0010, 12},
+ {0x1200, 7}, {0x7a00, 7}, {0xb800, 6}, {0x3200, 7},
+ {0x2200, 7}, {0xf600, 8}, {0x3d00, 8}, {0x9e00, 9},
+ {0xbd80, 9}, {0x7c80, 9}, {0x0080, 9}, {0xaa00, 9},
+ {0xbd00, 9}, {0x9f00, 9}, {0x0300, 8}, {0xab78, 13},
+ {0xab68, 13}, {0x3c00, 9}, {0x3000, 9}, {0x0020, 11},
+ {0x7d50, 12}, {0x3800, 7}, {0x7800, 7}, {0x9c00, 7},
+ {0xfe00, 7}, {0x2400, 6}, {0xbc00, 8}, {0x0200, 8},
+ {0x0100, 8}, {0xf100, 8}, {0x0040, 11}, {0x3100, 8},
+ {0xf200, 8}, {0x3400, 7}, {0x1c00, 7}, {0x1e00, 7},
+ {0xbe00, 7}, {0xaba0, 11}, {0x3e00, 7}, {0x1400, 6},
+ {0x3600, 7}, {0xf380, 9}, {0xf080, 9}, {0x2000, 8},
+ {0xfc00, 8}, {0x9f80, 10}, {0x9e80, 9}, {0xab90, 12},
+ {0x3b80, 9}, {0xab80, 12}, {0xab54, 14}, {0x3a50, 13},
+ {0xab50, 14}, {0xa000, 5}, {0x1800, 6}, {0x9800, 6},
+ {0x7000, 5}, {0x4000, 3}, {0x0400, 6}, {0xac00, 6},
+ {0xf800, 6}, {0x6000, 4}, {0x3a00, 10}, {0xfd00, 8},
+ {0x2800, 5}, {0xb000, 6}, {0x8000, 4}, {0xb400, 6},
+ {0x1000, 7}, {0x7d20, 12}, {0xe000, 5}, {0x9000, 5},
+ {0xe800, 5}, {0x0800, 5}, {0xf700, 8}, {0xa800, 7},
+ {0x7d80, 9}, {0xf300, 10}, {0x7e00, 7}, {0xab48, 14},
+ {0x3a48, 13}, {0xab4c, 14}, {0x3a60, 12}, {0x9ffc, 15},
+ {0x9fec, 15}, {0x2100, 8}, {0x9fdc, 15}, {0x9fcc, 15},
+ {0xf000, 9}, {0x7d7c, 15}, {0x7d6c, 15}, {0x3a40, 14},
+ {0xab40, 15}, {0xab38, 15}, {0xab30, 15}, {0xab28, 15},
+ {0xab20, 15}, {0xab18, 15}, {0xab70, 13}, {0xab10, 15},
+ {0xab08, 15}, {0xab00, 15}, {0xaaf8, 15}, {0xaaf0, 15},
+ {0x3b00, 9}, {0xaae8, 15}, {0xaae0, 15}, {0xaad8, 15},
+ {0xaad0, 15}, {0xab64, 14}, {0x7d30, 12}, {0xaac8, 15},
+ {0xaac0, 15}, {0xaab8, 15}, {0xaab0, 15}, {0xaaa8, 15},
+ {0xaaa0, 15}, {0xaa98, 15}, {0xaa90, 15}, {0xaa88, 15},
+ {0xaa80, 15}, {0x9ff8, 15}, {0x9ff0, 15}, {0x9fe8, 15},
+ {0x9fe0, 15}, {0x9fd8, 15}, {0x9fd0, 15}, {0x9fc8, 15},
+ {0x9fc0, 15}, {0x7d78, 15}, {0x7d70, 15}, {0x3a58, 13},
+ {0x7d68, 15}, {0x7d60, 15}, {0xab46, 15}, {0xab42, 15},
+ {0xab3e, 15}, {0xab3a, 15}, {0xab36, 15}, {0xab32, 15},
+ {0xab2e, 15}, {0xab2a, 15}, {0xab26, 15}, {0xab22, 15},
+ {0xab1e, 15}, {0xab1a, 15}, {0xab16, 15}, {0xab12, 15},
+ {0xab0e, 15}, {0xab0a, 15}, {0xab06, 15}, {0xab02, 15},
+ {0xaafe, 15}, {0xaafa, 15}, {0xaaf6, 15}, {0xaaf2, 15},
+ {0xaaee, 15}, {0xaaea, 15}, {0xaae6, 15}, {0xaae2, 15},
+ {0xaade, 15}, {0xaada, 15}, {0xaad6, 15}, {0xaad2, 15},
+ {0xaace, 15}, {0xaaca, 15}, {0xaac6, 15}, {0xaac2, 15},
+ {0xaabe, 15}, {0xaaba, 15}, {0xaab6, 15}, {0xaab2, 15},
+ {0xaaae, 15}, {0xaaaa, 15}, {0xaaa6, 15}, {0xaaa2, 15},
+ {0xaa9e, 15}, {0x3a70, 12}, {0xaa9a, 15}, {0xaa96, 15},
+ {0xaa92, 15}, {0x3080, 9}, {0xaa8e, 15}, {0xaa8a, 15},
+ {0xaa86, 15}, {0xaa82, 15}, {0x9ffe, 15}, {0x9ffa, 15},
+ {0x9ff6, 15}, {0x9ff2, 15}, {0x9fee, 15}, {0x9fea, 15},
+ {0x9fe6, 15}, {0x9fe2, 15}, {0x9fde, 15}, {0x9fda, 15},
+ {0x9fd6, 15}, {0x9fd2, 15}, {0x9fce, 15}, {0x9fca, 15},
+ {0x9fc6, 15}, {0x9fc2, 15}, {0x7d7e, 15}, {0x7d7a, 15},
+ {0x7d76, 15}, {0x7d72, 15}, {0x7d6e, 15}, {0x7d6a, 15},
+ {0x7d66, 15}, {0x7d62, 15}, {0x3a46, 15}, {0x3a44, 15}
};
/* huffman decoding table */
static struct huffdecodtab huffdecodtab[] = {
{ 79, 1},{ 2, 66},{ 24, 3},{ 4,208},
-{292, 5},{ 6,298},{317, 7},{ 16, 8},
-{ 9,173},{ 10,116},{ 41, 11},{ 12, 37},
-{125, 13},{357, 14},{ 15,438},{ 0, 0},
-{229, 17},{ 18, 46},{ 19, 61},{ 20, 99},
-{ 21,161},{404, 22},{ 23,483},{ 1, 0},
-{306, 25},{313, 26},{294, 27},{245, 28},
-{221, 29},{231, 30},{277, 31},{ 32,103},
-{ 33,108},{ 34,339},{421, 35},{ 36,500},
-{ 2, 0},{122, 38},{353, 39},{ 40,434},
-{ 3, 0},{131, 42},{128, 43},{361, 44},
-{ 45,442},{ 4, 0},{ 56, 47},{ 52, 48},
-{135, 49},{370, 50},{ 51,450},{ 5, 0},
-{138, 53},{375, 54},{ 55,454},{ 6, 0},
-{148, 57},{ 58, 94},{381, 59},{ 60,460},
-{ 7, 0},{ 75, 62},{ 63,152},{392, 64},
-{ 65,469},{ 8, 0},{164, 67},{311, 68},
-{ 69,246},{ 70, 97},{253, 71},{257, 72},
-{ 73,270},{319, 74},{ 9, 0},{ 76,155},
-{396, 77},{ 78,473},{ 10, 0},{165, 80},
-{296, 81},{300, 82},{295, 83},{206, 84},
-{ 85,320},{193, 86},{ 87,318},{199, 88},
-{184, 89},{ 90,112},{ 91,346},{430, 92},
-{ 93,508},{ 11, 0},{379, 95},{ 96,458},
-{ 12, 0},{ 98,218},{ 13, 0},{100,158},
-{400,101},{102,478},{ 14, 0},{331,104},
-{105,328},{408,106},{107,487},{ 15, 0},
-{109,336},{417,110},{111,496},{ 16, 0},
-{113,343},{425,114},{115,504},{ 17, 0},
-{117,141},{118,186},{119,321},{351,120},
-{121,432},{ 18, 0},{355,123},{124,436},
-{ 19, 0},{359,126},{127,440},{ 20, 0},
-{364,129},{130,444},{ 21, 0},{132,145},
-{368,133},{134,448},{ 22, 0},{372,136},
-{137,452},{ 23, 0},{377,139},{140,456},
-{ 24, 0},{142,234},{143,236},{144,383},
-{ 25, 0},{366,146},{147,446},{ 26, 0},
-{387,149},{385,150},{151,462},{ 27, 0},
-{390,153},{154,467},{ 28, 0},{394,156},
-{157,471},{ 29, 0},{398,159},{160,475},
-{ 30, 0},{402,162},{163,481},{ 31, 0},
-{ 32, 0},{175,166},{214,167},{211,168},
-{169,195},{243,170},{171,281},{286,172},
-{ 33, 0},{265,174},{ 34, 0},{176,202},
-{177,315},{178,297},{179,232},{180,252},
-{181,228},{189,182},{255,183},{ 35, 0},
-{185,242},{ 36, 0},{284,187},{192,188},
-{ 37, 0},{190,241},{191,201},{ 38, 0},
-{ 39, 0},{194,227},{ 40, 0},{196,267},
-{197,220},{237,198},{ 41, 0},{200,309},
-{ 42, 0},{ 43, 0},{203,260},{204,268},
-{308,205},{ 44, 0},{244,207},{ 45, 0},
-{304,209},{210,223},{ 46, 0},{212,258},
-{238,213},{ 47, 0},{215,303},{216,249},
-{273,217},{ 48, 0},{219,316},{ 49, 0},
-{ 50, 0},{222,278},{ 51, 0},{224,264},
-{250,225},{230,226},{ 52, 0},{ 53, 0},
-{ 54, 0},{ 55, 0},{ 56, 0},{ 57, 0},
-{251,233},{ 58, 0},{363,235},{ 59, 0},
-{ 60, 0},{ 61, 0},{239,256},{240,480},
-{ 62, 0},{ 63, 0},{ 64, 0},{ 65, 0},
-{ 66, 0},{ 67, 0},{299,247},{275,248},
-{ 68, 0},{ 69, 0},{ 70, 0},{ 71, 0},
-{ 72, 0},{271,254},{ 73, 0},{ 74, 0},
-{ 75, 0},{ 76, 0},{259,269},{ 77, 0},
-{293,261},{262,263},{ 78, 0},{ 79, 0},
-{ 80, 0},{279,266},{ 81, 0},{ 82, 0},
-{ 83, 0},{ 84, 0},{ 85, 0},{342,272},
-{ 86, 0},{274,335},{ 87, 0},{276,302},
-{ 88, 0},{ 89, 0},{ 90, 0},{283,280},
-{ 91, 0},{374,282},{ 92, 0},{ 93, 0},
-{291,285},{ 94, 0},{301,287},{288,326},
-{323,289},{290,427},{ 95, 0},{ 96, 0},
-{ 97, 0},{ 98, 0},{ 99, 0},{100, 0},
-{101, 0},{102, 0},{103, 0},{104, 0},
-{105, 0},{106, 0},{107, 0},{108, 0},
-{305,307},{109, 0},{110, 0},{111, 0},
-{112, 0},{310,384},{113, 0},{312,314},
-{114, 0},{115, 0},{116, 0},{117, 0},
-{118, 0},{119, 0},{120, 0},{121, 0},
-{122, 0},{322,325},{123, 0},{349,324},
-{124, 0},{125, 0},{327,476},{126, 0},
-{406,329},{330,485},{127, 0},{412,332},
-{410,333},{334,489},{128, 0},{129, 0},
-{415,337},{338,494},{130, 0},{419,340},
-{341,498},{131, 0},{132, 0},{423,344},
-{345,502},{133, 0},{428,347},{348,506},
-{134, 0},{350,510},{135, 0},{352,433},
-{136, 0},{354,435},{137, 0},{356,437},
-{138, 0},{358,439},{139, 0},{360,441},
-{140, 0},{362,443},{141, 0},{142, 0},
-{365,445},{143, 0},{367,447},{144, 0},
-{369,449},{145, 0},{371,451},{146, 0},
-{373,453},{147, 0},{148, 0},{376,455},
-{149, 0},{378,457},{150, 0},{380,459},
-{151, 0},{382,461},{152, 0},{153, 0},
-{154, 0},{386,463},{155, 0},{388,464},
-{389,466},{156, 0},{391,468},{157, 0},
-{393,470},{158, 0},{395,472},{159, 0},
-{397,474},{160, 0},{399,477},{161, 0},
-{401,479},{162, 0},{403,482},{163, 0},
-{405,484},{164, 0},{407,486},{165, 0},
-{409,488},{166, 0},{411,490},{167, 0},
-{413,491},{414,493},{168, 0},{416,495},
-{169, 0},{418,497},{170, 0},{420,499},
-{171, 0},{422,501},{172, 0},{424,503},
-{173, 0},{426,505},{174, 0},{175, 0},
-{429,507},{176, 0},{431,509},{177, 0},
-{178, 0},{179, 0},{180, 0},{181, 0},
-{182, 0},{183, 0},{184, 0},{185, 0},
-{186, 0},{187, 0},{188, 0},{189, 0},
-{190, 0},{191, 0},{192, 0},{193, 0},
-{194, 0},{195, 0},{196, 0},{197, 0},
-{198, 0},{199, 0},{200, 0},{201, 0},
-{202, 0},{203, 0},{204, 0},{205, 0},
-{206, 0},{207, 0},{208, 0},{209, 0},
-{ 0,465},{210, 0},{211, 0},{212, 0},
-{213, 0},{214, 0},{215, 0},{216, 0},
-{217, 0},{218, 0},{219, 0},{220, 0},
-{221, 0},{222, 0},{223, 0},{224, 0},
-{225, 0},{226, 0},{227, 0},{228, 0},
-{229, 0},{230, 0},{231, 0},{232, 0},
-{233, 0},{234, 0},{235, 0},{ 0,492},
-{236, 0},{237, 0},{238, 0},{239, 0},
-{240, 0},{241, 0},{242, 0},{243, 0},
-{244, 0},{245, 0},{246, 0},{247, 0},
-{248, 0},{249, 0},{250, 0},{251, 0},
-{252, 0},{253, 0},{512,511},{254, 0},
-{255, 0}
+ {292, 5}, { 6,298}, {317, 7}, { 16, 8},
+ { 9,173}, { 10,116}, { 41, 11}, { 12, 37},
+ {125, 13}, {357, 14}, { 15,438}, { 0, 0},
+ {229, 17}, { 18, 46}, { 19, 61}, { 20, 99},
+ { 21,161}, {404, 22}, { 23,483}, { 1, 0},
+ {306, 25}, {313, 26}, {294, 27}, {245, 28},
+ {221, 29}, {231, 30}, {277, 31}, { 32,103},
+ { 33,108}, { 34,339}, {421, 35}, { 36,500},
+ { 2, 0}, {122, 38}, {353, 39}, { 40,434},
+ { 3, 0}, {131, 42}, {128, 43}, {361, 44},
+ { 45,442}, { 4, 0}, { 56, 47}, { 52, 48},
+ {135, 49}, {370, 50}, { 51,450}, { 5, 0},
+ {138, 53}, {375, 54}, { 55,454}, { 6, 0},
+ {148, 57}, { 58, 94}, {381, 59}, { 60,460},
+ { 7, 0}, { 75, 62}, { 63,152}, {392, 64},
+ { 65,469}, { 8, 0}, {164, 67}, {311, 68},
+ { 69,246}, { 70, 97}, {253, 71}, {257, 72},
+ { 73,270}, {319, 74}, { 9, 0}, { 76,155},
+ {396, 77}, { 78,473}, { 10, 0}, {165, 80},
+ {296, 81}, {300, 82}, {295, 83}, {206, 84},
+ { 85,320}, {193, 86}, { 87,318}, {199, 88},
+ {184, 89}, { 90,112}, { 91,346}, {430, 92},
+ { 93,508}, { 11, 0}, {379, 95}, { 96,458},
+ { 12, 0}, { 98,218}, { 13, 0}, {100,158},
+ {400,101}, {102,478}, { 14, 0}, {331,104},
+ {105,328}, {408,106}, {107,487}, { 15, 0},
+ {109,336}, {417,110}, {111,496}, { 16, 0},
+ {113,343}, {425,114}, {115,504}, { 17, 0},
+ {117,141}, {118,186}, {119,321}, {351,120},
+ {121,432}, { 18, 0}, {355,123}, {124,436},
+ { 19, 0}, {359,126}, {127,440}, { 20, 0},
+ {364,129}, {130,444}, { 21, 0}, {132,145},
+ {368,133}, {134,448}, { 22, 0}, {372,136},
+ {137,452}, { 23, 0}, {377,139}, {140,456},
+ { 24, 0}, {142,234}, {143,236}, {144,383},
+ { 25, 0}, {366,146}, {147,446}, { 26, 0},
+ {387,149}, {385,150}, {151,462}, { 27, 0},
+ {390,153}, {154,467}, { 28, 0}, {394,156},
+ {157,471}, { 29, 0}, {398,159}, {160,475},
+ { 30, 0}, {402,162}, {163,481}, { 31, 0},
+ { 32, 0}, {175,166}, {214,167}, {211,168},
+ {169,195}, {243,170}, {171,281}, {286,172},
+ { 33, 0}, {265,174}, { 34, 0}, {176,202},
+ {177,315}, {178,297}, {179,232}, {180,252},
+ {181,228}, {189,182}, {255,183}, { 35, 0},
+ {185,242}, { 36, 0}, {284,187}, {192,188},
+ { 37, 0}, {190,241}, {191,201}, { 38, 0},
+ { 39, 0}, {194,227}, { 40, 0}, {196,267},
+ {197,220}, {237,198}, { 41, 0}, {200,309},
+ { 42, 0}, { 43, 0}, {203,260}, {204,268},
+ {308,205}, { 44, 0}, {244,207}, { 45, 0},
+ {304,209}, {210,223}, { 46, 0}, {212,258},
+ {238,213}, { 47, 0}, {215,303}, {216,249},
+ {273,217}, { 48, 0}, {219,316}, { 49, 0},
+ { 50, 0}, {222,278}, { 51, 0}, {224,264},
+ {250,225}, {230,226}, { 52, 0}, { 53, 0},
+ { 54, 0}, { 55, 0}, { 56, 0}, { 57, 0},
+ {251,233}, { 58, 0}, {363,235}, { 59, 0},
+ { 60, 0}, { 61, 0}, {239,256}, {240,480},
+ { 62, 0}, { 63, 0}, { 64, 0}, { 65, 0},
+ { 66, 0}, { 67, 0}, {299,247}, {275,248},
+ { 68, 0}, { 69, 0}, { 70, 0}, { 71, 0},
+ { 72, 0}, {271,254}, { 73, 0}, { 74, 0},
+ { 75, 0}, { 76, 0}, {259,269}, { 77, 0},
+ {293,261}, {262,263}, { 78, 0}, { 79, 0},
+ { 80, 0}, {279,266}, { 81, 0}, { 82, 0},
+ { 83, 0}, { 84, 0}, { 85, 0}, {342,272},
+ { 86, 0}, {274,335}, { 87, 0}, {276,302},
+ { 88, 0}, { 89, 0}, { 90, 0}, {283,280},
+ { 91, 0}, {374,282}, { 92, 0}, { 93, 0},
+ {291,285}, { 94, 0}, {301,287}, {288,326},
+ {323,289}, {290,427}, { 95, 0}, { 96, 0},
+ { 97, 0}, { 98, 0}, { 99, 0}, {100, 0},
+ {101, 0}, {102, 0}, {103, 0}, {104, 0},
+ {105, 0}, {106, 0}, {107, 0}, {108, 0},
+ {305,307}, {109, 0}, {110, 0}, {111, 0},
+ {112, 0}, {310,384}, {113, 0}, {312,314},
+ {114, 0}, {115, 0}, {116, 0}, {117, 0},
+ {118, 0}, {119, 0}, {120, 0}, {121, 0},
+ {122, 0}, {322,325}, {123, 0}, {349,324},
+ {124, 0}, {125, 0}, {327,476}, {126, 0},
+ {406,329}, {330,485}, {127, 0}, {412,332},
+ {410,333}, {334,489}, {128, 0}, {129, 0},
+ {415,337}, {338,494}, {130, 0}, {419,340},
+ {341,498}, {131, 0}, {132, 0}, {423,344},
+ {345,502}, {133, 0}, {428,347}, {348,506},
+ {134, 0}, {350,510}, {135, 0}, {352,433},
+ {136, 0}, {354,435}, {137, 0}, {356,437},
+ {138, 0}, {358,439}, {139, 0}, {360,441},
+ {140, 0}, {362,443}, {141, 0}, {142, 0},
+ {365,445}, {143, 0}, {367,447}, {144, 0},
+ {369,449}, {145, 0}, {371,451}, {146, 0},
+ {373,453}, {147, 0}, {148, 0}, {376,455},
+ {149, 0}, {378,457}, {150, 0}, {380,459},
+ {151, 0}, {382,461}, {152, 0}, {153, 0},
+ {154, 0}, {386,463}, {155, 0}, {388,464},
+ {389,466}, {156, 0}, {391,468}, {157, 0},
+ {393,470}, {158, 0}, {395,472}, {159, 0},
+ {397,474}, {160, 0}, {399,477}, {161, 0},
+ {401,479}, {162, 0}, {403,482}, {163, 0},
+ {405,484}, {164, 0}, {407,486}, {165, 0},
+ {409,488}, {166, 0}, {411,490}, {167, 0},
+ {413,491}, {414,493}, {168, 0}, {416,495},
+ {169, 0}, {418,497}, {170, 0}, {420,499},
+ {171, 0}, {422,501}, {172, 0}, {424,503},
+ {173, 0}, {426,505}, {174, 0}, {175, 0},
+ {429,507}, {176, 0}, {431,509}, {177, 0},
+ {178, 0}, {179, 0}, {180, 0}, {181, 0},
+ {182, 0}, {183, 0}, {184, 0}, {185, 0},
+ {186, 0}, {187, 0}, {188, 0}, {189, 0},
+ {190, 0}, {191, 0}, {192, 0}, {193, 0},
+ {194, 0}, {195, 0}, {196, 0}, {197, 0},
+ {198, 0}, {199, 0}, {200, 0}, {201, 0},
+ {202, 0}, {203, 0}, {204, 0}, {205, 0},
+ {206, 0}, {207, 0}, {208, 0}, {209, 0},
+ { 0,465}, {210, 0}, {211, 0}, {212, 0},
+ {213, 0}, {214, 0}, {215, 0}, {216, 0},
+ {217, 0}, {218, 0}, {219, 0}, {220, 0},
+ {221, 0}, {222, 0}, {223, 0}, {224, 0},
+ {225, 0}, {226, 0}, {227, 0}, {228, 0},
+ {229, 0}, {230, 0}, {231, 0}, {232, 0},
+ {233, 0}, {234, 0}, {235, 0}, { 0,492},
+ {236, 0}, {237, 0}, {238, 0}, {239, 0},
+ {240, 0}, {241, 0}, {242, 0}, {243, 0},
+ {244, 0}, {245, 0}, {246, 0}, {247, 0},
+ {248, 0}, {249, 0}, {250, 0}, {251, 0},
+ {252, 0}, {253, 0}, {512,511}, {254, 0},
+ {255, 0}
};
static unsigned char mask8tab[8] = {
- 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01
+ 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
};
static unsigned short mask16tab[16] = {
- 0x8000,0x4000,0x2000,0x1000,0x0800,0x0400,0x0200,0x0100,
- 0x0080,0x0040,0x0020,0x0010,0x0008,0x0004,0x0002,0x0001
+ 0x8000, 0x4000, 0x2000, 0x1000, 0x0800, 0x0400, 0x0200, 0x0100,
+ 0x0080, 0x0040, 0x0020, 0x0010, 0x0008, 0x0004, 0x0002, 0x0001
};
char policy_add_user = 1;
-char policy_add_empty_password = 0;
-char policy_add_prog_useradd = 0;
+char policy_add_empty_password;
+char policy_add_prog_useradd;
char policy_guest = 1;
-char policy_associate = 0;
+char policy_associate;
char pwcheck = 1;
-char secure_home = 0;
+char secure_home;
gid_t user_gid = 400;
char *user_shell = "/bin/bash";
@@ -445,8 +445,8 @@ int start_uid = 400;
int end_uid = 65535;
int paclen = ROSE_PACLEN; /* Its the shortest ie safest */
-int huffman = 0;
-int bin = 0;
+int huffman;
+int bin;
int fdmaster;
struct write_queue {
@@ -455,8 +455,8 @@ struct write_queue {
unsigned int len;
};
-struct write_queue *wqueue_head = NULL;
-struct write_queue *wqueue_tail = NULL;
+struct write_queue *wqueue_head;
+struct write_queue *wqueue_tail;
long wqueue_length = 0L;
@@ -511,7 +511,7 @@ int Strncasecmp(const char *s1, const char *s2, int n)
pid_t forkpty(int *, char *, void *, struct winsize *);
/* The buffer in src (first byte length-1) is decoded into dest
- (first byte length-1). If decoding is not successful, non-0
+ (first byte length-1). If decoding is not successful, non-0
is returned
*/
@@ -524,14 +524,14 @@ int encstathuf(char *src, int srclen, char *dest, int *destlen)
int bit8;
unsigned short huffcode;
int hufflen;
-
+
if ((src == NULL) || (dest == NULL)) {
syslog(LOG_NOTICE, "Huffman encode: src or dest NULL!");
- return(1);
+ return 1;
}
if (srclen > 255) {
syslog(LOG_NOTICE, "Huffman encode: srclen > 255: %d", srclen);
- return(1);
+ return 1;
}
srcptr = src;
destptr = &dest[1];
@@ -554,7 +554,7 @@ int encstathuf(char *src, int srclen, char *dest, int *destlen)
memcpy(&dest[1],src,srclen);
dest[0] = 255;
*destlen = srclen + 1;
- return(0);
+ return 0;
}
bit8 = 0;
*destptr = 0;
@@ -572,11 +572,11 @@ int encstathuf(char *src, int srclen, char *dest, int *destlen)
if (bit8 != 0) (*destlen)++;
(*destlen)++;
dest[0] = (char)(srclen-1);
- return(0);
+ return 0;
}
/* The buffer in src (first byte length-1) is decoded into dest
- (first byte length-1). If decoding is not successful, non-0
+ (first byte length-1). If decoding is not successful, non-0
is returned
*/
@@ -590,24 +590,24 @@ int decstathuf(char *src, char *dest, int srclen, int *destlen)
unsigned short decod;
unsigned short newnode;
- if ((src == NULL) || (dest == NULL)) return(1);
+ if ((src == NULL) || (dest == NULL)) return 1;
srcptr = src;
destptr = dest;
*destlen = (int)((*srcptr)+1);
srcptr++;
if (--srclen == 0) {
- return(1);
+ return 1;
}
if (*destlen == 0) {
- return(1);
+ return 1;
}
if (*destlen == 256) {
/* no compression, only copy */
memcpy(dest,src+1,srclen);
*destlen = (unsigned char)(srclen);
- return(0);
+ return 0;
}
wrklen = 0;
decod = 0;
@@ -641,10 +641,10 @@ int decstathuf(char *src, char *dest, int srclen, int *destlen)
if (wrklen >= *destlen) break;
bitmask = 0x80;
srcptr++;
- if (srclen == 0) return(1);
+ if (srclen == 0) return 1;
srclen--;
}
- return(0);
+ return 0;
}
@@ -656,7 +656,7 @@ int _write_ax25(const char *s, int len)
i = write(1, s, len);
fflush(stdout);
- return (i > 0 ? i : 0); /* on error, -1 is returned */
+ return i > 0 ? i : 0; /* on error, -1 is returned */
}
int read_ax25(unsigned char *s, int size)
@@ -673,19 +673,19 @@ int read_ax25(unsigned char *s, int size)
if (huffman) {
if (!decstathuf(s, decomp, len, &declen)) {
- *(decomp+declen) = 0;
+ *(decomp+declen) = 0;
strcpy(s, decomp);
len = declen;
}
}
if (bin) {
- return(len);
+ return len;
}
-
+
for (k = 0; k < len; k++)
if (s[k] == '\r') s[k] = '\n';
-
+
if (!huffman && !Strncasecmp(s, "//COMP ON\n", 10)) {
sprintf(buffer,"\r//COMP 1\r");
@@ -748,7 +748,7 @@ void kick_wqueue(int dummy)
int bufsize = (huffman ? 256-1 : paclen);
char decoded[260];
int declen;
-
+
signal(SIGALRM, SIG_IGN);
itv.it_value.tv_sec = 0;
itv.it_value.tv_usec = QUEUE_DELAY;
@@ -769,7 +769,7 @@ void kick_wqueue(int dummy)
}
p = s;
s_len = 0;
-
+
while ((w_buf = wqueue_head)) {
curr_len = (w_buf->len > bufsize-s_len ? bufsize-s_len : w_buf->len);
memcpy(p, w_buf->data, curr_len);
@@ -778,7 +778,7 @@ void kick_wqueue(int dummy)
if (w_buf->len > curr_len) {
/* rewrite current buffer, and break */
w_buf->len -= curr_len;
- for (q = w_buf->data, r = w_buf->data+curr_len, i = 0; i < w_buf->len; i++)
+ for (q = w_buf->data, r = w_buf->data+curr_len, i = 0; i < w_buf->len; i++)
*q++ = *r++;
break;
}
@@ -823,7 +823,7 @@ void kick_wqueue(int dummy)
wqueue_head = w_buf->next;
free(w_buf->data);
free(w_buf);
-
+
if (!wqueue_head) {
wqueue_tail = NULL;
return;
@@ -835,7 +835,7 @@ void kick_wqueue(int dummy)
* new data is available in order to send "full packets"
*/
if (wqueue_length < paclen)
- break;
+ break;
}
itv.it_interval.tv_sec = 0;
@@ -852,12 +852,12 @@ int write_ax25(char *s, int len, int kick)
struct termios termios;
static struct termios save_termios;
static struct termios save_termios_master;
- static int last_ended_with_CR = 0;
+ static int last_ended_with_CR;
int i = 0;
int j = 0;
char *p;
-
+
if (!len)
return 0;
signal(SIGALRM, SIG_IGN);
@@ -881,7 +881,7 @@ int write_ax25(char *s, int len, int kick)
bin = 1;
kick_wqueue(0);
return 0;
- }
+ }
if (bin && !strncmp(s, "//BIN OFF\r", 10)) {
kick_wqueue(0);
@@ -890,7 +890,7 @@ int write_ax25(char *s, int len, int kick)
tcsetattr(0, TCSANOW, &save_termios);
last_ended_with_CR = 0;
return 0;
- }
+ }
if (!bin) {
@@ -912,12 +912,12 @@ int write_ax25(char *s, int len, int kick)
}
while (j < len) {
if ((j + 1 < len) && *(p + j) == '\r' && *(p + j + 1) == '\n') {
- *(p + i) = '\r';
+ *(p + i) = '\r';
j++;
}
else
*(p + i) = *(p + j);
- i++; j++;
+ i++; j++;
}
len = i;
if (len && s[len-1] == '\r')
@@ -937,8 +937,8 @@ int write_ax25(char *s, int len, int kick)
memcpy(buf->data, s, len);
buf->len = len;
- buf->next = NULL;
-
+ buf->next = NULL;
+
if (wqueue_head == NULL)
{
wqueue_head = buf;
@@ -949,7 +949,7 @@ int write_ax25(char *s, int len, int kick)
wqueue_tail = buf;
wqueue_length += len;
}
-
+
if (wqueue_length > 7*paclen || kick || bin)
{
kick_wqueue(0);
@@ -969,13 +969,13 @@ int get_assoc(struct sockaddr_ax25 *sax25)
FILE *fp;
int uid;
char buf[81];
-
+
fp = fopen(PROC_AX25_CALLS_FILE, "r");
if (!fp) return -1;
-
+
fgets(buf, sizeof(buf)-1, fp);
-
- while(!feof(fp))
+
+ while (!feof(fp))
{
if (fscanf(fp, "%d %s", &uid, buf) == 2)
if (sax25->sax25_uid == uid)
@@ -986,7 +986,7 @@ int get_assoc(struct sockaddr_ax25 *sax25)
}
}
fclose(fp);
-
+
return -1;
}
@@ -1037,8 +1037,8 @@ void signal_handler_sigchild(int dummy)
{
exit(0);
}
-
-/*
+
+/*
* add a new user to /etc/passwd and do some init
*/
@@ -1058,7 +1058,7 @@ void new_user(char *newuser)
struct stat fst;
int fd_a, fd_b, fd_l;
mode_t homedir_mode = S_IRUSR|S_IWUSR|S_IXUSR|S_IXOTH|(secure_home ? 0 : (S_IRGRP|S_IXGRP));
-
+
/*
* build path for home directory
*/
@@ -1090,14 +1090,14 @@ retry:
/*
* build directories for home
*/
-
+
p = homedir;
-
+
while (*p == '/') p++;
chdir("/");
- while(p)
+ while (p)
{
q = strchr(p, '/');
if (q)
@@ -1135,12 +1135,12 @@ retry:
{
chown(p, uid, user_gid);
chmod(p, homedir_mode);
- }
+ }
}
else
goto out;
}
-
+
if (chdir(p) < 0)
goto out;
p = q;
@@ -1156,16 +1156,16 @@ end_mkdirs:
pid_t pid = -1;
struct stat statbuf;
if (!user_shell_configured && stat(USERADD_CONF, &statbuf) == -1) {
- /* some programs need a shell explicitely specified
- * in /etc/passwd, although this field is not required
- * (and useradd does not set a shell when not
- * specified).
- * useradd has a config file. On debian for e.g.,
- * there is no /etc/default/useradd. Thus we
- * explecitely give the shell option to useradd, when
- * no useradd config file is present.
- */
- user_shell_configured = 1;
+ /* some programs need a shell explicitely specified
+ * in /etc/passwd, although this field is not required
+ * (and useradd does not set a shell when not
+ * specified).
+ * useradd has a config file. On debian for e.g.,
+ * there is no /etc/default/useradd. Thus we
+ * explecitely give the shell option to useradd, when
+ * no useradd config file is present.
+ */
+ user_shell_configured = 1;
}
pid = fork();
@@ -1218,7 +1218,7 @@ end_mkdirs:
fp = fopen(PASSWDFILE, "a+");
if (fp == NULL)
goto out;
-
+
pw.pw_name = newuser;
pw.pw_passwd = ((policy_add_empty_password) ? "" : "+");
pw.pw_uid = uid;
@@ -1226,12 +1226,12 @@ end_mkdirs:
pw.pw_gecos = username;
pw.pw_dir = userdir;
pw.pw_shell = user_shell;
-
+
if (getpwuid(uid) != NULL) goto retry; /* oops?! */
if (putpwent(&pw, fp) < 0)
goto out;
-
+
fclose(fp);
}
@@ -1241,7 +1241,7 @@ end_mkdirs:
*/
fd_a = open(CONF_AXSPAWN_PROF_FILE, O_RDONLY);
-
+
if (fd_a > 0)
{
int first = 1;
@@ -1249,7 +1249,7 @@ end_mkdirs:
if (fd_b < 0)
goto out;
-
+
/* just 2b sure */
if (lseek(fd_b, 0L, SEEK_END) > 0L)
write(fd_b, "\n", 1);
@@ -1264,7 +1264,7 @@ end_mkdirs:
* as an optimization.
* -> mark #!... as ##
*/
- if (buf[0] == '#' && buf[1] == '!')
+ if (buf[0] == '#' && buf[1] == '!')
buf[1] = '#';
first = 0;
}
@@ -1284,16 +1284,16 @@ void read_config(void)
char buf[512];
char cmd[40], param[80];
char *p;
-
+
if (fp == NULL)
return;
-
+
while (!feof(fp))
{
fgets(buf, sizeof(buf), fp);
if ((p = strchr(buf, '#')) || (p = strchr(buf, '\n')))
*p='\0';
-
+
if (buf[0] != '\0')
{
sscanf(buf, "%s %s", cmd, param);
@@ -1359,12 +1359,12 @@ void read_config(void)
} else
if (!strncmp(cmd, "secure_home", 11)) {
secure_home = (param[0] == 'y');
- } else
+ } else
if (!strncmp(cmd, "assoc", 5))
{
if (!strcmp(param, "yes"))
policy_associate = 1;
- else
+ else
policy_associate = 0;
} else
if (!strncmp(cmd, "shell", 5))
@@ -1378,7 +1378,7 @@ void read_config(void)
}
}
}
-
+
fclose(fp);
}
@@ -1430,7 +1430,7 @@ int main(int argc, char **argv)
digits = letters = invalid = ssid = ssidcnt = 0;
- for (k = 1; k < argc; k++){
+ for (k = 1; k < argc; k++) {
if (!strcmp(argv[k], "-w") || !strcmp(argv[k], "--wait"))
wait_for_tcp = 1;
if (!strcmp(argv[k], "-c") || !strcmp(argv[k], "--changeuser"))
@@ -1463,7 +1463,7 @@ int main(int argc, char **argv)
}
}
strupr(prompt);
-
+
openlog("axspawn", LOG_PID, LOG_DAEMON);
if (getuid() != 0) {
@@ -1474,34 +1474,34 @@ int main(int argc, char **argv)
addrlen = sizeof(struct full_sockaddr_ax25);
k = getpeername(0, (struct sockaddr *) &sockaddr, &addrlen);
-
+
if (k < 0) {
syslog(LOG_NOTICE, "getpeername: %m\n");
return 1;
}
switch (sockaddr.fsax25.fsa_ax25.sax25_family) {
- case AF_AX25:
- strcpy(call, ax25_ntoa(&sockaddr.fsax25.fsa_ax25.sax25_call));
- protocol = "AX.25";
- paclen = AX_PACLEN;
- break;
-
- case AF_NETROM:
- strcpy(call, ax25_ntoa(&sockaddr.fsax25.fsa_ax25.sax25_call));
- protocol = "NET/ROM";
- paclen = NETROM_PACLEN;
- break;
-
- case AF_ROSE:
- strcpy(call, ax25_ntoa(&sockaddr.rose.srose_call));
- protocol = "Rose";
- paclen = ROSE_PACLEN;
- break;
-
- default:
- syslog(LOG_NOTICE, "peer is not an AX.25, NET/ROM or Rose socket\n");
- return 1;
+ case AF_AX25:
+ strcpy(call, ax25_ntoa(&sockaddr.fsax25.fsa_ax25.sax25_call));
+ protocol = "AX.25";
+ paclen = AX_PACLEN;
+ break;
+
+ case AF_NETROM:
+ strcpy(call, ax25_ntoa(&sockaddr.fsax25.fsa_ax25.sax25_call));
+ protocol = "NET/ROM";
+ paclen = NETROM_PACLEN;
+ break;
+
+ case AF_ROSE:
+ strcpy(call, ax25_ntoa(&sockaddr.rose.srose_call));
+ protocol = "Rose";
+ paclen = ROSE_PACLEN;
+ break;
+
+ default:
+ syslog(LOG_NOTICE, "peer is not an AX.25, NET/ROM or Rose socket\n");
+ return 1;
}
for (k = 0; k < strlen(call); k++)
@@ -1520,7 +1520,7 @@ int main(int argc, char **argv)
{
ssid *= 10;
ssid += (int) (call[k] - '0');
-
+
if (ssid > 15) invalid++;
}
ssidcnt++;
@@ -1544,7 +1544,7 @@ int main(int argc, char **argv)
else
invalid++;
}
-
+
if ( invalid || (k < MINLEN) || (digits > 2) || (digits < 1) )
{
write_ax25_static_line(MSG_NOCALL);
@@ -1552,7 +1552,7 @@ int main(int argc, char **argv)
sleep(EXITDELAY);
return 1;
}
-
+
if (wait_for_tcp) {
/* incoming TCP/IP connection? */
if (read_ax25(buf, sizeof(buf)) < 0)
@@ -1585,7 +1585,7 @@ int main(int argc, char **argv)
user_changed = 1;
}
}
-
+
if (!*as_user)
strcpy(as_user, user);
pw = getpwnam(as_user);
@@ -1599,7 +1599,7 @@ int main(int argc, char **argv)
return 1;
}
- if (policy_add_user)
+ if (policy_add_user)
{
new_user(as_user);
pw = getpwnam(as_user);
@@ -1610,7 +1610,7 @@ int main(int argc, char **argv)
return 1;
}
}
-
+
if (pw == NULL && policy_guest)
{
strcpy(as_user,guest);
@@ -1625,7 +1625,7 @@ int main(int argc, char **argv)
sleep(EXITDELAY);
return 1;
}
-
+
if (!rootlogin && (pw->pw_uid == 0 || pw->pw_gid == 0))
{
write_ax25_static_line(MSG_NOCALL);
@@ -1633,7 +1633,7 @@ int main(int argc, char **argv)
sleep(EXITDELAY);
return 1;
}
-
+
again:
if (!(pwd = read_pwd(pw, &pwtype))) {
if ((!pwtype || pwtype != PW_CLEARTEXT) && (pwtype != PW_UNIX)) {
@@ -1651,7 +1651,7 @@ again:
if (pwtype == PW_MD5)
ask_pw_md5(prompt, pass_want, pwd);
else
- ask_pw_sys(prompt, pass_want, pwd);
+ ask_pw_sys(prompt, pass_want, pwd);
cnt = read_ax25(buf, sizeof(buf)-1);
if (cnt <= 0) {
@@ -1705,58 +1705,58 @@ again:
if (get_assoc(&sax25) != -1)
ioctl(fds, SIOCAX25DELUID, &sax25);
switch (sockaddr.fsax25.fsa_ax25.sax25_family) {
- case AF_AX25:
- case AF_NETROM:
- sax25.sax25_call = sockaddr.fsax25.fsa_ax25.sax25_call;
- break;
- case AF_ROSE:
- sax25.sax25_call = sockaddr.rose.srose_call;
- break;
+ case AF_AX25:
+ case AF_NETROM:
+ sax25.sax25_call = sockaddr.fsax25.fsa_ax25.sax25_call;
+ break;
+ case AF_ROSE:
+ sax25.sax25_call = sockaddr.rose.srose_call;
+ break;
}
ioctl(fds, SIOCAX25ADDUID, &sax25);
close(fds);
}
}
-
+
fcntl(1, F_SETFL, O_NONBLOCK);
-
+
pid = forkpty(&fdmaster, ptyslave, NULL, &win);
-
+
if (pid == 0)
{
struct termios termios;
char *shell = "/bin/sh";
- memset((char *) &termios, 0, sizeof(termios));
-
- ioctl(0, TIOCSCTTY, (char *) 0);
+ memset((char *) &termios, 0, sizeof(termios));
+
+ ioctl(0, TIOCSCTTY, (char *) 0);
termios.c_iflag = ICRNL | IXOFF;
- termios.c_oflag = OPOST | ONLCR;
- termios.c_cflag = CS8 | CREAD | CLOCAL;
- termios.c_lflag = ISIG | ICANON;
- termios.c_cc[VINTR] = /* 127 */ 0x03;
- termios.c_cc[VQUIT] = 28;
- termios.c_cc[VERASE] = 8;
- termios.c_cc[VKILL] = 24;
- termios.c_cc[VEOF] = 4;
- cfsetispeed(&termios, B19200);
- cfsetospeed(&termios, B19200);
- tcsetattr(0, TCSANOW, &termios);
+ termios.c_oflag = OPOST | ONLCR;
+ termios.c_cflag = CS8 | CREAD | CLOCAL;
+ termios.c_lflag = ISIG | ICANON;
+ termios.c_cc[VINTR] = /* 127 */ 0x03;
+ termios.c_cc[VQUIT] = 28;
+ termios.c_cc[VERASE] = 8;
+ termios.c_cc[VKILL] = 24;
+ termios.c_cc[VEOF] = 4;
+ cfsetispeed(&termios, B19200);
+ cfsetospeed(&termios, B19200);
+ tcsetattr(0, TCSANOW, &termios);
setutent();
- ut_line.ut_type = LOGIN_PROCESS;
- ut_line.ut_pid = getpid();
- strncpy(ut_line.ut_line, ptyslave + 5, sizeof(ut_line.ut_line));
- strncpy(ut_line.ut_id, ptyslave + 8, sizeof(ut_line.ut_id));
- strncpy(ut_line.ut_user, "LOGIN", sizeof(ut_line.ut_user));
- strncpy(ut_line.ut_host, protocol, sizeof(ut_line.ut_host));
+ ut_line.ut_type = LOGIN_PROCESS;
+ ut_line.ut_pid = getpid();
+ strncpy(ut_line.ut_line, ptyslave + 5, sizeof(ut_line.ut_line));
+ strncpy(ut_line.ut_id, ptyslave + 8, sizeof(ut_line.ut_id));
+ strncpy(ut_line.ut_user, "LOGIN", sizeof(ut_line.ut_user));
+ strncpy(ut_line.ut_host, protocol, sizeof(ut_line.ut_host));
gettimeofday(&tv, NULL);
ut_line.ut_tv.tv_sec = tv.tv_sec;
ut_line.ut_tv.tv_usec = tv.tv_usec;
- ut_line.ut_addr = 0;
- pututline(&ut_line);
- endutent();
+ ut_line.ut_addr = 0;
+ pututline(&ut_line);
+ endutent();
/* become process group leader, if we not already are */
if (getpid() != getsid(0)) {
@@ -1764,8 +1764,8 @@ again:
exit(1);
}
- chargc = 0;
- envc = 0;
+ chargc = 0;
+ envc = 0;
if (dumb_embedded_system) {
int ret = -1;
@@ -1777,18 +1777,18 @@ again:
ret = -1;
if (pw->pw_dir && *(pw->pw_dir))
p = pw->pw_dir;
- ret = chdir(p);
+ ret = chdir(p);
if (ret != 0) {
p = "/tmp";
- chdir(p);
+ chdir(p);
}
- if ((envp[envc] = (char *) malloc(strlen(p)+6)))
- sprintf(envp[envc++], "HOME=%s", p);
- if ((envp[envc] = (char *) malloc(strlen(pw->pw_name)+6)))
- sprintf(envp[envc++], "USER=%s", pw->pw_name);
- if ((envp[envc] = (char *) malloc(strlen(pw->pw_name)+9)))
- sprintf(envp[envc++], "LOGNAME=%s", pw->pw_name);
+ if ((envp[envc] = (char *) malloc(strlen(p)+6)))
+ sprintf(envp[envc++], "HOME=%s", p);
+ if ((envp[envc] = (char *) malloc(strlen(pw->pw_name)+6)))
+ sprintf(envp[envc++], "USER=%s", pw->pw_name);
+ if ((envp[envc] = (char *) malloc(strlen(pw->pw_name)+9)))
+ sprintf(envp[envc++], "LOGNAME=%s", pw->pw_name);
if (pw->pw_shell && *(pw->pw_shell)) {
shell = pw->pw_shell;
@@ -1799,61 +1799,61 @@ again:
if (p[1]) {
if ((p = strdup(p)))
*p = '-';
-
+
} else p = 0;
}
if (!p)
p = shell;
- chargv[chargc++] = p;
- if ((envp[envc] = (char *) malloc(strlen(shell)+7)))
- sprintf(envp[envc++], "SHELL=%s", shell);
+ chargv[chargc++] = p;
+ if ((envp[envc] = (char *) malloc(strlen(shell)+7)))
+ sprintf(envp[envc++], "SHELL=%s", shell);
if (pw->pw_uid == 0)
p = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin";
else
p = "/bin:/usr/bin:/usr/local/bin";
- if ((envp[envc] = (char *) malloc(strlen(p)+6)))
- sprintf(envp[envc++], "PATH=%s", p);
+ if ((envp[envc] = (char *) malloc(strlen(p)+6)))
+ sprintf(envp[envc++], "PATH=%s", p);
} else {
- chargv[chargc++] = "/bin/login";
- chargv[chargc++] = "-p";
+ chargv[chargc++] = "/bin/login";
+ chargv[chargc++] = "-p";
/* there exist several conectps:
- * Historicaly, the special character '+' in the password
- * field indicated that users may login via ax25, netrom, rose,
- * etc.. - but not via other protocols like telnet.
- * This secures the digipeater from abuse by inet access of
- * non-hams.
- * On the other hand, this leads to the problem that telent
- * via HF, pop3, etc.. do not work.
- * The "pwcheck == 2 method means, that the password is used on
- * every login mechanism other than this axspawn program;
- * here we do not rely on the password - the ax25 call of
- * the ham is enough. We have already checked above, that
- * the call of the user is valid (and not root, httpd, etc..);
- * thus this method is safe here.
- * Another mechanism (pwcheck == 3) is to check if the gid
- * equals to user_gid preference. I prefer this way, because
- * this approach gives the chance to temporary lock a user
- * out (abuse, ..) by changing his gid in passwd to for e.g.
- * 65534 (nogroup).
- */
+ * Historicaly, the special character '+' in the password
+ * field indicated that users may login via ax25, netrom, rose,
+ * etc.. - but not via other protocols like telnet.
+ * This secures the digipeater from abuse by inet access of
+ * non-hams.
+ * On the other hand, this leads to the problem that telent
+ * via HF, pop3, etc.. do not work.
+ * The "pwcheck == 2 method means, that the password is used on
+ * every login mechanism other than this axspawn program;
+ * here we do not rely on the password - the ax25 call of
+ * the ham is enough. We have already checked above, that
+ * the call of the user is valid (and not root, httpd, etc..);
+ * thus this method is safe here.
+ * Another mechanism (pwcheck == 3) is to check if the gid
+ * equals to user_gid preference. I prefer this way, because
+ * this approach gives the chance to temporary lock a user
+ * out (abuse, ..) by changing his gid in passwd to for e.g.
+ * 65534 (nogroup).
+ */
chargv[chargc++] = "-h";
chargv[chargc++] = protocol;
- if (pwtype != PW_CLEARTEXT /* PW_SYS or PW_MD5 are already authenticated */
+ if (pwtype != PW_CLEARTEXT /* PW_SYS or PW_MD5 are already authenticated */
|| pwcheck == 2 || (pwcheck == 3 && (pw->pw_gid == user_gid || is_guest)) || !strcmp(pw->pw_passwd, "+"))
- chargv[chargc++] = "-f";
- chargv[chargc++] = as_user;
+ chargv[chargc++] = "-f";
+ chargv[chargc++] = as_user;
}
- chargv[chargc] = NULL;
-
- if ((envp[envc] = (char *) malloc(30)))
- sprintf(envp[envc++], "AXCALL=%s", call);
- if ((envp[envc] = (char *) malloc(30)))
- sprintf(envp[envc++], "CALL=%s", user);
- if ((envp[envc] = (char *) malloc(30)))
- sprintf(envp[envc++], "PROTOCOL=%s", protocol);
+ chargv[chargc] = NULL;
+
+ if ((envp[envc] = (char *) malloc(30)))
+ sprintf(envp[envc++], "AXCALL=%s", call);
+ if ((envp[envc] = (char *) malloc(30)))
+ sprintf(envp[envc++], "CALL=%s", user);
+ if ((envp[envc] = (char *) malloc(30)))
+ sprintf(envp[envc++], "PROTOCOL=%s", protocol);
if ((envp[envc] = (char *) malloc(30)))
sprintf(envp[envc++], "TERM=dumb"); /* SuSE bug (dump - tsts) */
/* other useful defaults */
@@ -1868,51 +1868,51 @@ again:
exit(1);
if (setuid(pw->pw_uid) == -1)
exit(1);
- execve(shell, chargv, envp);
+ execve(shell, chargv, envp);
/* point of no return */
exit(1);
}
- execve(chargv[0], chargv, envp);
+ execve(chargv[0], chargv, envp);
/* point of no return */
exit(1);
- }
- else if (pid > 0)
- {
- child_pid = 0;
- signal(SIGHUP, signal_handler);
- signal(SIGTERM, signal_handler);
- signal(SIGINT, signal_handler);
- signal(SIGQUIT, signal_handler);
-
- while(1)
- {
- FD_ZERO(&fds_read);
- FD_ZERO(&fds_err);
- FD_SET(0, &fds_read);
- FD_SET(0, &fds_err);
- if (wqueue_length <= paclen*7)
+ }
+ else if (pid > 0)
+ {
+ child_pid = 0;
+ signal(SIGHUP, signal_handler);
+ signal(SIGTERM, signal_handler);
+ signal(SIGINT, signal_handler);
+ signal(SIGQUIT, signal_handler);
+
+ while (1)
+ {
+ FD_ZERO(&fds_read);
+ FD_ZERO(&fds_err);
+ FD_SET(0, &fds_read);
+ FD_SET(0, &fds_err);
+ if (wqueue_length <= paclen*7)
FD_SET(fdmaster, &fds_read);
- FD_SET(fdmaster, &fds_err);
-
- k = select(fdmaster+1, &fds_read, NULL, &fds_err, NULL);
-
- if (k > 0)
- {
- if (FD_ISSET(0, &fds_err))
- {
+ FD_SET(fdmaster, &fds_err);
+
+ k = select(fdmaster+1, &fds_read, NULL, &fds_err, NULL);
+
+ if (k > 0)
+ {
+ if (FD_ISSET(0, &fds_err))
+ {
if (huffman) {
sprintf(buf,"\r//COMP 0\r");
write_ax25(buf, strlen(buf), 1);
sleep(EXITDELAY);
- }
- kill(pid, SIGHUP);
- cleanup(ptyslave+5);
- return 1;
- }
-
- if (FD_ISSET(fdmaster, &fds_err))
- {
+ }
+ kill(pid, SIGHUP);
+ cleanup(ptyslave+5);
+ return 1;
+ }
+
+ if (FD_ISSET(fdmaster, &fds_err))
+ {
/* give the last packet in the timer controlled sendqueue a chance.. */
if (wqueue_length) {
continue;
@@ -1921,28 +1921,28 @@ again:
sprintf(buf,"\r//COMP 0\r");
write_ax25(buf, strlen(buf), 1);
sleep(EXITDELAY);
- }
- cleanup(ptyslave+5);
- return 1;
- }
-
- if (FD_ISSET(0, &fds_read))
- {
- cnt = read_ax25(buf, sizeof(buf));
- if (cnt < 0) /* Connection died */
- {
- kill(pid, SIGHUP);
- cleanup(ptyslave+5);
- return 1;
- } else
- write(fdmaster, buf, cnt);
- }
-
- if (FD_ISSET(fdmaster, &fds_read))
- {
- cnt = read(fdmaster, buf, (huffman ? 254 : sizeof(buf)));
- if (cnt < 0)
- {
+ }
+ cleanup(ptyslave+5);
+ return 1;
+ }
+
+ if (FD_ISSET(0, &fds_read))
+ {
+ cnt = read_ax25(buf, sizeof(buf));
+ if (cnt < 0) /* Connection died */
+ {
+ kill(pid, SIGHUP);
+ cleanup(ptyslave+5);
+ return 1;
+ } else
+ write(fdmaster, buf, cnt);
+ }
+
+ if (FD_ISSET(fdmaster, &fds_read))
+ {
+ cnt = read(fdmaster, buf, (huffman ? 254 : sizeof(buf)));
+ if (cnt < 0)
+ {
/* give the last packet in the timer controlled sendqueue a chance.. */
if (wqueue_length) {
continue;
@@ -1951,36 +1951,36 @@ again:
sprintf(buf,"\r//COMP 0\r");
write_ax25(buf, strlen(buf), 1);
sleep(EXITDELAY);
- }
- cleanup(ptyslave+5);
- return 1; /* Child died */
- }
- write_ax25(buf, cnt, 0);
- }
- } else
- if (k < 0 && errno != EINTR)
- {
+ }
+ cleanup(ptyslave+5);
+ return 1; /* Child died */
+ }
+ write_ax25(buf, cnt, 0);
+ }
+ } else
+ if (k < 0 && errno != EINTR)
+ {
if (huffman) {
sprintf(buf,"\r//COMP 0\r");
write_ax25(buf, strlen(buf), 1);
sleep(EXITDELAY);
- }
-
- kill(pid, SIGHUP); /* just in case... */
- cleanup(ptyslave+5);
- return 0;
- }
- }
- }
- else
- {
+ }
+
+ kill(pid, SIGHUP); /* just in case... */
+ cleanup(ptyslave+5);
+ return 0;
+ }
+ }
+ }
+ else
+ {
write_ax25_static_line(MSG_CANNOTFORK);
- syslog(LOG_ERR, "cannot fork %m, closing connection to %s\n", call);
- sleep(EXITDELAY);
- return 1;
- }
-
- sleep(EXITDELAY);
+ syslog(LOG_ERR, "cannot fork %m, closing connection to %s\n", call);
+ sleep(EXITDELAY);
+ return 1;
+ }
+
+ sleep(EXITDELAY);
return 0;
}
diff --git a/ax25/beacon.c b/ax25/beacon.c
index 095614f..ca229c7 100644
--- a/ax25/beacon.c
+++ b/ax25/beacon.c
@@ -26,7 +26,7 @@ static void terminate(int sig)
syslog(LOG_INFO, "terminating on SIGTERM\n");
closelog();
}
-
+
exit(0);
}
@@ -37,38 +37,38 @@ int main(int argc, char *argv[])
int s, n, dlen, len, interval = 30;
char *addr, *port, *message, *portcall;
char *srccall = NULL, *destcall = NULL;
-
+
while ((n = getopt(argc, argv, "c:d:lmst:v")) != -1) {
switch (n) {
- case 'c':
- srccall = optarg;
- break;
- case 'd':
- destcall = optarg;
- break;
- case 'l':
- logging = TRUE;
- break;
- case 'm':
- mail = TRUE;
- /* falls through */
- case 's':
- single = TRUE;
- break;
- case 't':
- interval = atoi(optarg);
- if (interval < 1) {
- fprintf(stderr, "beacon: interval must be greater than on minute\n");
- return 1;
- }
- break;
- case 'v':
- printf("beacon: %s\n", VERSION);
- return 0;
- case '?':
- case ':':
- fprintf(stderr, "usage: beacon [-c <src_call>] [-d <dest_call>] [-l] [-m] [-s] [-t interval] [-v] <port> <message>\n");
+ case 'c':
+ srccall = optarg;
+ break;
+ case 'd':
+ destcall = optarg;
+ break;
+ case 'l':
+ logging = TRUE;
+ break;
+ case 'm':
+ mail = TRUE;
+ /* falls through */
+ case 's':
+ single = TRUE;
+ break;
+ case 't':
+ interval = atoi(optarg);
+ if (interval < 1) {
+ fprintf(stderr, "beacon: interval must be greater than on minute\n");
return 1;
+ }
+ break;
+ case 'v':
+ printf("beacon: %s\n", VERSION);
+ return 0;
+ case '?':
+ case ':':
+ fprintf(stderr, "usage: beacon [-c <src_call>] [-d <dest_call>] [-l] [-m] [-s] [-t interval] [-v] <port> <message>\n");
+ return 1;
}
}
@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
port = argv[optind];
message = argv[optind + 1];
-
+
if (ax25_config_load_ports() == 0) {
fprintf(stderr, "beacon: no AX.25 ports defined\n");
return 1;
@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
else
addr = strdup("IDENT");
if (addr == NULL)
- return 1;
+ return 1;
if ((dlen = ax25_aton(addr, &dest)) == -1) {
fprintf(stderr, "beacon: unable to convert callsign '%s'\n", addr);
@@ -151,7 +151,7 @@ int main(int argc, char *argv[])
}
return 1;
}
-
+
if (sendto(s, message, strlen(message), 0, (struct sockaddr *)&dest, dlen) == -1) {
if (logging) {
syslog(LOG_ERR, "sendto: %m");
diff --git a/ax25/bpqparms.c b/ax25/bpqparms.c
index f8e9d66..83734a8 100644
--- a/ax25/bpqparms.c
+++ b/ax25/bpqparms.c
@@ -1,19 +1,19 @@
-/*
+/*
bpqparms.c
Copyright 1996, by Joerg Reuter jreuter@poboxes.com
- This program is free software; you can redistribute it and/or modify
- it under the terms of the (modified) GNU General Public License
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the (modified) GNU General Public License
delivered with the LinuX kernel source.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- You should find a copy of the GNU General Public License in
- /usr/src/linux/COPYING;
+ You should find a copy of the GNU General Public License in
+ /usr/src/linux/COPYING;
*/
@@ -54,9 +54,9 @@ int get_hwaddr(unsigned char *k, char *s)
if (strcmp(s, "default") == 0 || strcmp(s, "broadcast") == 0) {
memcpy(k, broadcast, ETH_ALEN);
} else {
- n = sscanf(s, "%x:%x:%x:%x:%x:%x",
+ n = sscanf(s, "%x:%x:%x:%x:%x:%x",
&eth[0], &eth[1], &eth[2], &eth[3], &eth[4], &eth[5]);
-
+
if (n < 6)
return 1;
@@ -79,64 +79,64 @@ int main(int argc, char **argv)
while ((cmd = getopt(argc, argv, "d:a:vVh")) != EOF) {
switch (cmd) {
- case 'd':
- flag |= 1;
- if (get_hwaddr(addr.destination, optarg)) {
- fprintf(stderr, "bpqparms: invalid 'destination' address %s\n", optarg);
- return 1;
- }
- break;
-
- case 'a':
- flag |= 2;
- if (get_hwaddr(addr.accept, optarg)) {
- fprintf(stderr, "bpqparms: invalid 'accept' address %s\n", optarg);
- return 1;
- }
- break;
-
- case 'V':
- printf("bpqparms version " VERSION "\n");
- printf("Copyright 1996, Jörg Reuter (jreuter@poboxes.com)\n");
- printf("This program is free software; you can redistribute it and/or modify\n");
- printf("it under the terms of the GNU General Public License as published by\n");
- printf("the Free Software Foundation; either version 2 of the License, or\n");
- printf(" (at your option) any later version.\n\n");
- printf("This program is distributed in the hope that it will be useful,\n");
- printf("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
- printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
- return 0;
-
- case 'v':
- printf("bpqparms: %s\n", VERSION);
- return(0);
-
- case 'h':
- case ':':
- case '?':
- usage();
+ case 'd':
+ flag |= 1;
+ if (get_hwaddr(addr.destination, optarg)) {
+ fprintf(stderr, "bpqparms: invalid 'destination' address %s\n", optarg);
+ return 1;
+ }
+ break;
+
+ case 'a':
+ flag |= 2;
+ if (get_hwaddr(addr.accept, optarg)) {
+ fprintf(stderr, "bpqparms: invalid 'accept' address %s\n", optarg);
+ return 1;
+ }
+ break;
+
+ case 'V':
+ printf("bpqparms version " VERSION "\n");
+ printf("Copyright 1996, Jörg Reuter (jreuter@poboxes.com)\n");
+ printf("This program is free software; you can redistribute it and/or modify\n");
+ printf("it under the terms of the GNU General Public License as published by\n");
+ printf("the Free Software Foundation; either version 2 of the License, or\n");
+ printf(" (at your option) any later version.\n\n");
+ printf("This program is distributed in the hope that it will be useful,\n");
+ printf("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
+ printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
+ return 0;
+
+ case 'v':
+ printf("bpqparms: %s\n", VERSION);
+ return 0;
+
+ case 'h':
+ case ':':
+ case '?':
+ usage();
}
}
-
+
if (!(flag & 0x01) || optind+1 > argc)
usage();
-
+
strcpy(dev, argv[optind]);
if ((flag & 0x02) == 0)
memcpy(addr.accept, addr.destination, ETH_ALEN);
fd = socket(AF_INET, SOCK_DGRAM, 0);
-
+
strcpy(ifr.ifr_name, dev);
ifr.ifr_data = (caddr_t) &addr;
-
+
if (ioctl(fd, SIOCSBPQETHADDR, &ifr) < 0) {
perror("bpqparms SIOCSBPQETHADDR");
close(fd);
return 1;
}
-
+
close(fd);
return 0;
diff --git a/ax25/md5.c b/ax25/md5.c
index 8bd0d11..d007b91 100644
--- a/ax25/md5.c
+++ b/ax25/md5.c
@@ -49,14 +49,14 @@
static void Transform(UINT4 *buf, UINT4 *in);
static unsigned char PADDING[64] = {
- 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* F, G, H and I are basic MD5 functions */
@@ -96,14 +96,14 @@ static unsigned char PADDING[64] = {
*/
void MD5Init(MD5_CTX *mdContext)
{
- mdContext->i[0] = mdContext->i[1] = (UINT4)0;
+ mdContext->i[0] = mdContext->i[1] = (UINT4)0;
- /* Load magic initialization constants.
- */
- mdContext->buf[0] = (UINT4)0x67452301;
- mdContext->buf[1] = (UINT4)0xefcdab89;
- mdContext->buf[2] = (UINT4)0x98badcfe;
- mdContext->buf[3] = (UINT4)0x10325476;
+ /* Load magic initialization constants.
+ */
+ mdContext->buf[0] = (UINT4)0x67452301;
+ mdContext->buf[1] = (UINT4)0xefcdab89;
+ mdContext->buf[2] = (UINT4)0x98badcfe;
+ mdContext->buf[3] = (UINT4)0x10325476;
}
/* The routine MD5Update updates the message-digest context to
@@ -112,34 +112,34 @@ void MD5Init(MD5_CTX *mdContext)
*/
void MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen)
{
- UINT4 in[16];
- int mdi;
- unsigned int i, ii;
+ UINT4 in[16];
+ int mdi;
+ unsigned int i, ii;
- /* compute number of bytes mod 64 */
- mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
+ /* compute number of bytes mod 64 */
+ mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
- /* update number of bits */
- if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0])
- mdContext->i[1]++;
- mdContext->i[0] += ((UINT4)inLen << 3);
- mdContext->i[1] += ((UINT4)inLen >> 29);
+ /* update number of bits */
+ if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0])
+ mdContext->i[1]++;
+ mdContext->i[0] += ((UINT4)inLen << 3);
+ mdContext->i[1] += ((UINT4)inLen >> 29);
- while (inLen--) {
- /* add new character to buffer, increment mdi */
- mdContext->in[mdi++] = *inBuf++;
+ while (inLen--) {
+ /* add new character to buffer, increment mdi */
+ mdContext->in[mdi++] = *inBuf++;
- /* transform if necessary */
- if (mdi == 0x40) {
- for (i = 0, ii = 0; i < 16; i++, ii += 4)
- in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
- (((UINT4)mdContext->in[ii+2]) << 16) |
- (((UINT4)mdContext->in[ii+1]) << 8) |
- ((UINT4)mdContext->in[ii]);
- Transform (mdContext->buf, in);
- mdi = 0;
- }
- }
+ /* transform if necessary */
+ if (mdi == 0x40) {
+ for (i = 0, ii = 0; i < 16; i++, ii += 4)
+ in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
+ (((UINT4)mdContext->in[ii+2]) << 16) |
+ (((UINT4)mdContext->in[ii+1]) << 8) |
+ ((UINT4)mdContext->in[ii]);
+ Transform (mdContext->buf, in);
+ mdi = 0;
+ }
+ }
}
/* The routine MD5Final terminates the message-digest computation and
@@ -147,140 +147,140 @@ void MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen)
*/
void MD5Final(MD5_CTX *mdContext)
{
- UINT4 in[16];
- int mdi;
- unsigned int i, ii;
- unsigned int padLen;
+ UINT4 in[16];
+ int mdi;
+ unsigned int i, ii;
+ unsigned int padLen;
- /* save number of bits */
- in[14] = mdContext->i[0];
- in[15] = mdContext->i[1];
+ /* save number of bits */
+ in[14] = mdContext->i[0];
+ in[15] = mdContext->i[1];
- /* compute number of bytes mod 64 */
- mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
+ /* compute number of bytes mod 64 */
+ mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
- /* pad out to 56 mod 64 */
- padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
- MD5Update (mdContext, PADDING, padLen);
+ /* pad out to 56 mod 64 */
+ padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
+ MD5Update (mdContext, PADDING, padLen);
- /* append length in bits and transform */
- for (i = 0, ii = 0; i < 14; i++, ii += 4)
- in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
- (((UINT4)mdContext->in[ii+2]) << 16) |
- (((UINT4)mdContext->in[ii+1]) << 8) |
- ((UINT4)mdContext->in[ii]);
- Transform (mdContext->buf, in);
+ /* append length in bits and transform */
+ for (i = 0, ii = 0; i < 14; i++, ii += 4)
+ in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
+ (((UINT4)mdContext->in[ii+2]) << 16) |
+ (((UINT4)mdContext->in[ii+1]) << 8) |
+ ((UINT4)mdContext->in[ii]);
+ Transform (mdContext->buf, in);
- /* store buffer in digest */
- for (i = 0, ii = 0; i < 4; i++, ii += 4) {
- mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
- mdContext->digest[ii+1] =
- (unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
- mdContext->digest[ii+2] =
- (unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
- mdContext->digest[ii+3] =
- (unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
- }
+ /* store buffer in digest */
+ for (i = 0, ii = 0; i < 4; i++, ii += 4) {
+ mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
+ mdContext->digest[ii+1] =
+ (unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
+ mdContext->digest[ii+2] =
+ (unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
+ mdContext->digest[ii+3] =
+ (unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
+ }
}
/* Basic MD5 step. Transforms buf based on in.
*/
static void Transform(UINT4 *buf, UINT4 *in)
{
- UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
+ UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
/* Round 1 */
#define S11 7
#define S12 12
#define S13 17
#define S14 22
- FF ( a, b, c, d, in[ 0], S11, 3614090360UL); /* 1 */
- FF ( d, a, b, c, in[ 1], S12, 3905402710UL); /* 2 */
- FF ( c, d, a, b, in[ 2], S13, 606105819UL); /* 3 */
- FF ( b, c, d, a, in[ 3], S14, 3250441966UL); /* 4 */
- FF ( a, b, c, d, in[ 4], S11, 4118548399UL); /* 5 */
- FF ( d, a, b, c, in[ 5], S12, 1200080426UL); /* 6 */
- FF ( c, d, a, b, in[ 6], S13, 2821735955UL); /* 7 */
- FF ( b, c, d, a, in[ 7], S14, 4249261313UL); /* 8 */
- FF ( a, b, c, d, in[ 8], S11, 1770035416UL); /* 9 */
- FF ( d, a, b, c, in[ 9], S12, 2336552879UL); /* 10 */
- FF ( c, d, a, b, in[10], S13, 4294925233UL); /* 11 */
- FF ( b, c, d, a, in[11], S14, 2304563134UL); /* 12 */
- FF ( a, b, c, d, in[12], S11, 1804603682UL); /* 13 */
- FF ( d, a, b, c, in[13], S12, 4254626195UL); /* 14 */
- FF ( c, d, a, b, in[14], S13, 2792965006UL); /* 15 */
- FF ( b, c, d, a, in[15], S14, 1236535329UL); /* 16 */
+ FF ( a, b, c, d, in[ 0], S11, 3614090360UL); /* 1 */
+ FF ( d, a, b, c, in[ 1], S12, 3905402710UL); /* 2 */
+ FF ( c, d, a, b, in[ 2], S13, 606105819UL); /* 3 */
+ FF ( b, c, d, a, in[ 3], S14, 3250441966UL); /* 4 */
+ FF ( a, b, c, d, in[ 4], S11, 4118548399UL); /* 5 */
+ FF ( d, a, b, c, in[ 5], S12, 1200080426UL); /* 6 */
+ FF ( c, d, a, b, in[ 6], S13, 2821735955UL); /* 7 */
+ FF ( b, c, d, a, in[ 7], S14, 4249261313UL); /* 8 */
+ FF ( a, b, c, d, in[ 8], S11, 1770035416UL); /* 9 */
+ FF ( d, a, b, c, in[ 9], S12, 2336552879UL); /* 10 */
+ FF ( c, d, a, b, in[10], S13, 4294925233UL); /* 11 */
+ FF ( b, c, d, a, in[11], S14, 2304563134UL); /* 12 */
+ FF ( a, b, c, d, in[12], S11, 1804603682UL); /* 13 */
+ FF ( d, a, b, c, in[13], S12, 4254626195UL); /* 14 */
+ FF ( c, d, a, b, in[14], S13, 2792965006UL); /* 15 */
+ FF ( b, c, d, a, in[15], S14, 1236535329UL); /* 16 */
/* Round 2 */
#define S21 5
#define S22 9
#define S23 14
#define S24 20
- GG ( a, b, c, d, in[ 1], S21, 4129170786UL); /* 17 */
- GG ( d, a, b, c, in[ 6], S22, 3225465664UL); /* 18 */
- GG ( c, d, a, b, in[11], S23, 643717713UL); /* 19 */
- GG ( b, c, d, a, in[ 0], S24, 3921069994UL); /* 20 */
- GG ( a, b, c, d, in[ 5], S21, 3593408605UL); /* 21 */
- GG ( d, a, b, c, in[10], S22, 38016083UL); /* 22 */
- GG ( c, d, a, b, in[15], S23, 3634488961UL); /* 23 */
- GG ( b, c, d, a, in[ 4], S24, 3889429448UL); /* 24 */
- GG ( a, b, c, d, in[ 9], S21, 568446438UL); /* 25 */
- GG ( d, a, b, c, in[14], S22, 3275163606UL); /* 26 */
- GG ( c, d, a, b, in[ 3], S23, 4107603335UL); /* 27 */
- GG ( b, c, d, a, in[ 8], S24, 1163531501UL); /* 28 */
- GG ( a, b, c, d, in[13], S21, 2850285829UL); /* 29 */
- GG ( d, a, b, c, in[ 2], S22, 4243563512UL); /* 30 */
- GG ( c, d, a, b, in[ 7], S23, 1735328473UL); /* 31 */
- GG ( b, c, d, a, in[12], S24, 2368359562UL); /* 32 */
+ GG ( a, b, c, d, in[ 1], S21, 4129170786UL); /* 17 */
+ GG ( d, a, b, c, in[ 6], S22, 3225465664UL); /* 18 */
+ GG ( c, d, a, b, in[11], S23, 643717713UL); /* 19 */
+ GG ( b, c, d, a, in[ 0], S24, 3921069994UL); /* 20 */
+ GG ( a, b, c, d, in[ 5], S21, 3593408605UL); /* 21 */
+ GG ( d, a, b, c, in[10], S22, 38016083UL); /* 22 */
+ GG ( c, d, a, b, in[15], S23, 3634488961UL); /* 23 */
+ GG ( b, c, d, a, in[ 4], S24, 3889429448UL); /* 24 */
+ GG ( a, b, c, d, in[ 9], S21, 568446438UL); /* 25 */
+ GG ( d, a, b, c, in[14], S22, 3275163606UL); /* 26 */
+ GG ( c, d, a, b, in[ 3], S23, 4107603335UL); /* 27 */
+ GG ( b, c, d, a, in[ 8], S24, 1163531501UL); /* 28 */
+ GG ( a, b, c, d, in[13], S21, 2850285829UL); /* 29 */
+ GG ( d, a, b, c, in[ 2], S22, 4243563512UL); /* 30 */
+ GG ( c, d, a, b, in[ 7], S23, 1735328473UL); /* 31 */
+ GG ( b, c, d, a, in[12], S24, 2368359562UL); /* 32 */
/* Round 3 */
#define S31 4
#define S32 11
#define S33 16
#define S34 23
- HH ( a, b, c, d, in[ 5], S31, 4294588738UL); /* 33 */
- HH ( d, a, b, c, in[ 8], S32, 2272392833UL); /* 34 */
- HH ( c, d, a, b, in[11], S33, 1839030562UL); /* 35 */
- HH ( b, c, d, a, in[14], S34, 4259657740UL); /* 36 */
- HH ( a, b, c, d, in[ 1], S31, 2763975236UL); /* 37 */
- HH ( d, a, b, c, in[ 4], S32, 1272893353UL); /* 38 */
- HH ( c, d, a, b, in[ 7], S33, 4139469664UL); /* 39 */
- HH ( b, c, d, a, in[10], S34, 3200236656UL); /* 40 */
- HH ( a, b, c, d, in[13], S31, 681279174UL); /* 41 */
- HH ( d, a, b, c, in[ 0], S32, 3936430074UL); /* 42 */
- HH ( c, d, a, b, in[ 3], S33, 3572445317UL); /* 43 */
- HH ( b, c, d, a, in[ 6], S34, 76029189UL); /* 44 */
- HH ( a, b, c, d, in[ 9], S31, 3654602809UL); /* 45 */
- HH ( d, a, b, c, in[12], S32, 3873151461UL); /* 46 */
- HH ( c, d, a, b, in[15], S33, 530742520UL); /* 47 */
- HH ( b, c, d, a, in[ 2], S34, 3299628645UL); /* 48 */
+ HH ( a, b, c, d, in[ 5], S31, 4294588738UL); /* 33 */
+ HH ( d, a, b, c, in[ 8], S32, 2272392833UL); /* 34 */
+ HH ( c, d, a, b, in[11], S33, 1839030562UL); /* 35 */
+ HH ( b, c, d, a, in[14], S34, 4259657740UL); /* 36 */
+ HH ( a, b, c, d, in[ 1], S31, 2763975236UL); /* 37 */
+ HH ( d, a, b, c, in[ 4], S32, 1272893353UL); /* 38 */
+ HH ( c, d, a, b, in[ 7], S33, 4139469664UL); /* 39 */
+ HH ( b, c, d, a, in[10], S34, 3200236656UL); /* 40 */
+ HH ( a, b, c, d, in[13], S31, 681279174UL); /* 41 */
+ HH ( d, a, b, c, in[ 0], S32, 3936430074UL); /* 42 */
+ HH ( c, d, a, b, in[ 3], S33, 3572445317UL); /* 43 */
+ HH ( b, c, d, a, in[ 6], S34, 76029189UL); /* 44 */
+ HH ( a, b, c, d, in[ 9], S31, 3654602809UL); /* 45 */
+ HH ( d, a, b, c, in[12], S32, 3873151461UL); /* 46 */
+ HH ( c, d, a, b, in[15], S33, 530742520UL); /* 47 */
+ HH ( b, c, d, a, in[ 2], S34, 3299628645UL); /* 48 */
/* Round 4 */
#define S41 6
#define S42 10
#define S43 15
#define S44 21
- II ( a, b, c, d, in[ 0], S41, 4096336452UL); /* 49 */
- II ( d, a, b, c, in[ 7], S42, 1126891415UL); /* 50 */
- II ( c, d, a, b, in[14], S43, 2878612391UL); /* 51 */
- II ( b, c, d, a, in[ 5], S44, 4237533241UL); /* 52 */
- II ( a, b, c, d, in[12], S41, 1700485571UL); /* 53 */
- II ( d, a, b, c, in[ 3], S42, 2399980690UL); /* 54 */
- II ( c, d, a, b, in[10], S43, 4293915773UL); /* 55 */
- II ( b, c, d, a, in[ 1], S44, 2240044497UL); /* 56 */
- II ( a, b, c, d, in[ 8], S41, 1873313359UL); /* 57 */
- II ( d, a, b, c, in[15], S42, 4264355552UL); /* 58 */
- II ( c, d, a, b, in[ 6], S43, 2734768916UL); /* 59 */
- II ( b, c, d, a, in[13], S44, 1309151649UL); /* 60 */
- II ( a, b, c, d, in[ 4], S41, 4149444226UL); /* 61 */
- II ( d, a, b, c, in[11], S42, 3174756917UL); /* 62 */
- II ( c, d, a, b, in[ 2], S43, 718787259UL); /* 63 */
- II ( b, c, d, a, in[ 9], S44, 3951481745UL); /* 64 */
+ II ( a, b, c, d, in[ 0], S41, 4096336452UL); /* 49 */
+ II ( d, a, b, c, in[ 7], S42, 1126891415UL); /* 50 */
+ II ( c, d, a, b, in[14], S43, 2878612391UL); /* 51 */
+ II ( b, c, d, a, in[ 5], S44, 4237533241UL); /* 52 */
+ II ( a, b, c, d, in[12], S41, 1700485571UL); /* 53 */
+ II ( d, a, b, c, in[ 3], S42, 2399980690UL); /* 54 */
+ II ( c, d, a, b, in[10], S43, 4293915773UL); /* 55 */
+ II ( b, c, d, a, in[ 1], S44, 2240044497UL); /* 56 */
+ II ( a, b, c, d, in[ 8], S41, 1873313359UL); /* 57 */
+ II ( d, a, b, c, in[15], S42, 4264355552UL); /* 58 */
+ II ( c, d, a, b, in[ 6], S43, 2734768916UL); /* 59 */
+ II ( b, c, d, a, in[13], S44, 1309151649UL); /* 60 */
+ II ( a, b, c, d, in[ 4], S41, 4149444226UL); /* 61 */
+ II ( d, a, b, c, in[11], S42, 3174756917UL); /* 62 */
+ II ( c, d, a, b, in[ 2], S43, 718787259UL); /* 63 */
+ II ( b, c, d, a, in[ 9], S44, 3951481745UL); /* 64 */
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
}
/*
diff --git a/ax25/md5.h b/ax25/md5.h
index fc45c8a..898479e 100644
--- a/ax25/md5.h
+++ b/ax25/md5.h
@@ -50,10 +50,10 @@ typedef unsigned long int UINT4;
/* Data structure for MD5 (Message-Digest) computation */
typedef struct {
- UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
- UINT4 buf[4]; /* scratch buffer */
- unsigned char in[64]; /* input buffer */
- unsigned char digest[16]; /* actual digest after MD5Final call */
+ UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
+ UINT4 buf[4]; /* scratch buffer */
+ unsigned char in[64]; /* input buffer */
+ unsigned char digest[16]; /* actual digest after MD5Final call */
} MD5_CTX;
void MD5Init(MD5_CTX *mdContext);
diff --git a/ax25/mheard.c b/ax25/mheard.c
index 5aeacf4..2370a46 100644
--- a/ax25/mheard.c
+++ b/ax25/mheard.c
@@ -35,23 +35,23 @@ static char *types[] = {
"UI",
"????"};
-static struct PortRecord *PortList = NULL;
+static struct PortRecord *PortList;
static void PrintHeader(int data)
{
switch (data) {
- case 0:
- printf("Callsign Port Packets Last Heard\n");
- break;
- case 1:
- printf("Callsign Port\n");
- break;
- case 2:
- printf("Callsign Port #I #S #U First Heard Last Heard\n");
- break;
- case 3:
- printf("Callsign Port Packets Type PIDs\n");
- break;
+ case 0:
+ printf("Callsign Port Packets Last Heard\n");
+ break;
+ case 1:
+ printf("Callsign Port\n");
+ break;
+ case 2:
+ printf("Callsign Port #I #S #U First Heard Last Heard\n");
+ break;
+ case 3:
+ printf("Callsign Port Packets Type PIDs\n");
+ break;
}
}
@@ -62,81 +62,81 @@ static void PrintPortEntry(struct PortRecord *pr, int data)
int i;
switch (data) {
- case 0:
- strcpy(lh, ctime(&pr->entry.last_heard));
- lh[19] = 0;
- call = ax25_ntoa(&pr->entry.from_call);
- if ((s = strstr(call, "-0")) != NULL)
- *s = '\0';
- printf("%-10s %-5s %5d %s\n",
- call, pr->entry.portname, pr->entry.count, lh);
- break;
- case 1:
- buffer[0] = '\0';
- call = ax25_ntoa(&pr->entry.from_call);
- if ((s = strstr(call, "-0")) != NULL)
- *s = '\0';
- strcat(buffer, call);
- call = ax25_ntoa(&pr->entry.to_call);
+ case 0:
+ strcpy(lh, ctime(&pr->entry.last_heard));
+ lh[19] = 0;
+ call = ax25_ntoa(&pr->entry.from_call);
+ if ((s = strstr(call, "-0")) != NULL)
+ *s = '\0';
+ printf("%-10s %-5s %5d %s\n",
+ call, pr->entry.portname, pr->entry.count, lh);
+ break;
+ case 1:
+ buffer[0] = '\0';
+ call = ax25_ntoa(&pr->entry.from_call);
+ if ((s = strstr(call, "-0")) != NULL)
+ *s = '\0';
+ strcat(buffer, call);
+ call = ax25_ntoa(&pr->entry.to_call);
+ if ((s = strstr(call, "-0")) != NULL)
+ *s = '\0';
+ strcat(buffer, ">");
+ strcat(buffer, call);
+ for (i = 0; i < pr->entry.ndigis && i < 4; i++) {
+ strcat(buffer, ",");
+ call = ax25_ntoa(&pr->entry.digis[i]);
if ((s = strstr(call, "-0")) != NULL)
*s = '\0';
- strcat(buffer, ">");
strcat(buffer, call);
- for (i = 0; i < pr->entry.ndigis && i < 4; i++) {
- strcat(buffer, ",");
- call = ax25_ntoa(&pr->entry.digis[i]);
- if ((s = strstr(call, "-0")) != NULL)
- *s = '\0';
- strcat(buffer, call);
- }
- if (pr->entry.ndigis >= 4)
- strcat(buffer, ",...");
- printf("%-70s %-5s\n",
- buffer, pr->entry.portname);
- break;
- case 2:
- strcpy(lh, ctime(&pr->entry.last_heard));
- lh[19] = 0;
- strcpy(fh, ctime(&pr->entry.first_heard));
- fh[19] = 0;
- call = ax25_ntoa(&pr->entry.from_call);
- if ((s = strstr(call, "-0")) != NULL)
- *s = '\0';
- printf("%-10s %-5s %5d %5d %5d %s %s\n",
- call, pr->entry.portname, pr->entry.iframes, pr->entry.sframes, pr->entry.uframes, fh, lh);
- break;
- case 3:
- call = ax25_ntoa(&pr->entry.from_call);
- if ((s = strstr(call, "-0")) != NULL)
- *s = '\0';
- printf("%-10s %-5s %5d %5s ",
- call, pr->entry.portname, pr->entry.count, types[pr->entry.type]);
- if (pr->entry.mode & MHEARD_MODE_ARP)
- printf(" ARP");
- if (pr->entry.mode & MHEARD_MODE_FLEXNET)
- printf(" FlexNet");
- if (pr->entry.mode & MHEARD_MODE_IP_DG)
- printf(" IP-DG");
- if (pr->entry.mode & MHEARD_MODE_IP_VC)
- printf(" IP-VC");
- if (pr->entry.mode & MHEARD_MODE_NETROM)
- printf(" NET/ROM");
- if (pr->entry.mode & MHEARD_MODE_ROSE)
- printf(" Rose");
- if (pr->entry.mode & MHEARD_MODE_SEGMENT)
- printf(" Segment");
- if (pr->entry.mode & MHEARD_MODE_TEXNET)
- printf(" TexNet");
- if (pr->entry.mode & MHEARD_MODE_TEXT)
- printf(" Text");
- if (pr->entry.mode & MHEARD_MODE_PSATFT)
- printf(" PacsatFT");
- if (pr->entry.mode & MHEARD_MODE_PSATPB)
- printf(" PacsatPB");
- if (pr->entry.mode & MHEARD_MODE_UNKNOWN)
- printf(" Unknown");
- printf("\n");
- break;
+ }
+ if (pr->entry.ndigis >= 4)
+ strcat(buffer, ",...");
+ printf("%-70s %-5s\n",
+ buffer, pr->entry.portname);
+ break;
+ case 2:
+ strcpy(lh, ctime(&pr->entry.last_heard));
+ lh[19] = 0;
+ strcpy(fh, ctime(&pr->entry.first_heard));
+ fh[19] = 0;
+ call = ax25_ntoa(&pr->entry.from_call);
+ if ((s = strstr(call, "-0")) != NULL)
+ *s = '\0';
+ printf("%-10s %-5s %5d %5d %5d %s %s\n",
+ call, pr->entry.portname, pr->entry.iframes, pr->entry.sframes, pr->entry.uframes, fh, lh);
+ break;
+ case 3:
+ call = ax25_ntoa(&pr->entry.from_call);
+ if ((s = strstr(call, "-0")) != NULL)
+ *s = '\0';
+ printf("%-10s %-5s %5d %5s ",
+ call, pr->entry.portname, pr->entry.count, types[pr->entry.type]);
+ if (pr->entry.mode & MHEARD_MODE_ARP)
+ printf(" ARP");
+ if (pr->entry.mode & MHEARD_MODE_FLEXNET)
+ printf(" FlexNet");
+ if (pr->entry.mode & MHEARD_MODE_IP_DG)
+ printf(" IP-DG");
+ if (pr->entry.mode & MHEARD_MODE_IP_VC)
+ printf(" IP-VC");
+ if (pr->entry.mode & MHEARD_MODE_NETROM)
+ printf(" NET/ROM");
+ if (pr->entry.mode & MHEARD_MODE_ROSE)
+ printf(" Rose");
+ if (pr->entry.mode & MHEARD_MODE_SEGMENT)
+ printf(" Segment");
+ if (pr->entry.mode & MHEARD_MODE_TEXNET)
+ printf(" TexNet");
+ if (pr->entry.mode & MHEARD_MODE_TEXT)
+ printf(" Text");
+ if (pr->entry.mode & MHEARD_MODE_PSATFT)
+ printf(" PacsatFT");
+ if (pr->entry.mode & MHEARD_MODE_PSATPB)
+ printf(" PacsatPB");
+ if (pr->entry.mode & MHEARD_MODE_UNKNOWN)
+ printf(" Unknown");
+ printf("\n");
+ break;
}
}
@@ -286,7 +286,7 @@ static void SortByFrame(void)
p = n;
}
}
-
+
int main(int argc, char *argv[])
{
int headers = TRUE;
@@ -296,64 +296,64 @@ int main(int argc, char *argv[])
while ((c = getopt(argc, argv, "d:no:v")) != -1) {
switch (c) {
- case 'd':
- switch (*optarg) {
- case 'c':
- data = 1;
- break;
- case 'm':
- data = 3;
- break;
- case 'n':
- data = 0;
- break;
- case 's':
- data = 2;
- break;
- default:
- fprintf(stderr, "mheard: invalid display type '%s'\n", optarg);
- return 1;
- }
+ case 'd':
+ switch (*optarg) {
+ case 'c':
+ data = 1;
+ break;
+ case 'm':
+ data = 3;
break;
case 'n':
- headers = FALSE;
+ data = 0;
+ break;
+ case 's':
+ data = 2;
+ break;
+ default:
+ fprintf(stderr, "mheard: invalid display type '%s'\n", optarg);
+ return 1;
+ }
+ break;
+ case 'n':
+ headers = FALSE;
+ break;
+ case 'o':
+ switch (*optarg) {
+ case 'c':
+ mode = 2;
+ break;
+ case 'f':
+ mode = 3;
break;
- case 'o':
- switch (*optarg) {
- case 'c':
- mode = 2;
- break;
- case 'f':
- mode = 3;
- break;
- case 'p':
- mode = 1;
- break;
- case 't':
- mode = 0;
- break;
- default:
- fprintf(stderr, "mheard: invalid ordering type '%s'\n", optarg);
- return 1;
- }
+ case 'p':
+ mode = 1;
break;
- case 'v':
- printf("mheard: %s\n", VERSION);
- return 0;
- case '?':
- case ':':
- fprintf(stderr, "Usage: %s [-d cmns] [-n] [-o cfpt] [-v] [port ...]\n", argv[0]);
+ case 't':
+ mode = 0;
+ break;
+ default:
+ fprintf(stderr, "mheard: invalid ordering type '%s'\n", optarg);
return 1;
+ }
+ break;
+ case 'v':
+ printf("mheard: %s\n", VERSION);
+ return 0;
+ case '?':
+ case ':':
+ fprintf(stderr, "Usage: %s [-d cmns] [-n] [-o cfpt] [-v] [port ...]\n", argv[0]);
+ return 1;
}
}
-
+
LoadPortData();
switch (mode) {
- case 0: SortByTime(); break;
- case 1: SortByPort(); break;
- case 2: SortByCall(); break;
- case 3: SortByFrame(); break;
+ case 0: SortByTime(); break;
+ case 1: SortByPort(); break;
+ case 2: SortByCall(); break;
+ case 3: SortByFrame(); break;
}
if (argc == optind) {
diff --git a/ax25/mheardd.8 b/ax25/mheardd.8
index c0dd200..be4a121 100644
--- a/ax25/mheardd.8
+++ b/ax25/mheardd.8
@@ -29,7 +29,7 @@ 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.
+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.
diff --git a/ax25/mheardd.c b/ax25/mheardd.c
index 3d45131..ec8cc2c 100644
--- a/ax25/mheardd.c
+++ b/ax25/mheardd.c
@@ -120,43 +120,43 @@ int main(int argc, char **argv)
*ports = 0;
while ((s = getopt(argc, argv, "fln:p:v")) != -1) {
switch (s) {
- case 'l':
- logging = TRUE;
- break;
- case 'f':
- flush = TRUE;
- break;
- case 'n':
- mheard_list_size = atoi(optarg);
- 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;
- case ':':
- fprintf(stderr, "mheardd: option -n needs an argument\n");
+ case 'l':
+ logging = TRUE;
+ break;
+ case 'f':
+ flush = TRUE;
+ break;
+ case 'n':
+ mheard_list_size = atoi(optarg);
+ 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;
- case '?':
- fprintf(stderr, "Usage: mheardd [-f] [-l] [-n number] [-p [!]port1[,port2,..]] [-v]\n");
+ }
+ 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;
+ case ':':
+ fprintf(stderr, "mheardd: option -n needs an argument\n");
+ return 1;
+ case '?':
+ fprintf(stderr, "Usage: mheardd [-f] [-l] [-n number] [-p [!]port1[,port2,..]] [-v]\n");
+ return 1;
}
}
@@ -187,7 +187,7 @@ int main(int argc, char **argv)
position = ftell(fp);
s++;
}
-
+
fclose(fp);
} else {
if ((fp = fopen(DATA_MHEARD_FILE, "w")) != NULL)
@@ -198,7 +198,7 @@ int main(int argc, char **argv)
perror("mheardd: socket");
return 1;
}
-
+
if (!daemon_start(FALSE)) {
fprintf(stderr, "mheardd: cannot become a daemon\n");
return 1;
@@ -220,7 +220,7 @@ int main(int argc, char **argv)
}
return 1;
}
-
+
if ((port = ax25_config_get_name(sa.sa_data)) == NULL) {
if (logging)
syslog(LOG_WARNING, "unknown port '%s'\n", sa.sa_data);
@@ -276,9 +276,9 @@ int main(int argc, char **argv)
while (!end) {
memcpy(&mheard->entry.digis[mheard->entry.ndigis], data, sizeof(ax25_address));
mheard->entry.ndigis++;
-
+
end = (data[ALEN] & HDLCAEB);
-
+
data += AXLEN;
size -= AXLEN;
}
@@ -294,103 +294,103 @@ int main(int argc, char **argv)
mheard->entry.count++;
switch (type) {
- case SABM:
- mheard->entry.type = MHEARD_TYPE_SABM;
- mheard->entry.uframes++;
- break;
- case SABME:
- mheard->entry.type = MHEARD_TYPE_SABME;
- mheard->entry.uframes++;
+ case SABM:
+ mheard->entry.type = MHEARD_TYPE_SABM;
+ mheard->entry.uframes++;
+ break;
+ case SABME:
+ mheard->entry.type = MHEARD_TYPE_SABME;
+ mheard->entry.uframes++;
+ break;
+ case DISC:
+ mheard->entry.type = MHEARD_TYPE_DISC;
+ mheard->entry.uframes++;
+ break;
+ case UA:
+ mheard->entry.type = MHEARD_TYPE_UA;
+ mheard->entry.uframes++;
+ break;
+ case DM:
+ mheard->entry.type = MHEARD_TYPE_DM;
+ mheard->entry.uframes++;
+ break;
+ case RR:
+ mheard->entry.type = MHEARD_TYPE_RR;
+ mheard->entry.sframes++;
+ break;
+ case RNR:
+ mheard->entry.type = MHEARD_TYPE_RNR;
+ mheard->entry.sframes++;
+ break;
+ case REJ:
+ mheard->entry.type = MHEARD_TYPE_REJ;
+ mheard->entry.sframes++;
+ break;
+ case FRMR:
+ mheard->entry.type = MHEARD_TYPE_FRMR;
+ mheard->entry.uframes++;
+ break;
+ case I:
+ mheard->entry.type = MHEARD_TYPE_I;
+ mheard->entry.iframes++;
+ break;
+ case UI:
+ mheard->entry.type = MHEARD_TYPE_UI;
+ mheard->entry.uframes++;
+ break;
+ default:
+ if (logging)
+ syslog(LOG_WARNING, "unknown packet type %02X\n", *data);
+ mheard->entry.type = MHEARD_TYPE_UNKNOWN;
+ break;
+ }
+
+ data += ctlen;
+ size -= ctlen;
+
+ if (type == I || type == UI) {
+ switch (*data) {
+ case PID_TEXT:
+ mheard->entry.mode |= MHEARD_MODE_TEXT;
break;
- case DISC:
- mheard->entry.type = MHEARD_TYPE_DISC;
- mheard->entry.uframes++;
+ case PID_SEGMENT:
+ mheard->entry.mode |= MHEARD_MODE_SEGMENT;
break;
- case UA:
- mheard->entry.type = MHEARD_TYPE_UA;
- mheard->entry.uframes++;
+ case PID_ARP:
+ mheard->entry.mode |= MHEARD_MODE_ARP;
break;
- case DM:
- mheard->entry.type = MHEARD_TYPE_DM;
- mheard->entry.uframes++;
+ case PID_NETROM:
+ mheard->entry.mode |= MHEARD_MODE_NETROM;
break;
- case RR:
- mheard->entry.type = MHEARD_TYPE_RR;
- mheard->entry.sframes++;
+ case PID_IP:
+ mheard->entry.mode |= (type == I) ? MHEARD_MODE_IP_VC : MHEARD_MODE_IP_DG;
break;
- case RNR:
- mheard->entry.type = MHEARD_TYPE_RNR;
- mheard->entry.sframes++;
+ case PID_ROSE:
+ mheard->entry.mode |= MHEARD_MODE_ROSE;
break;
- case REJ:
- mheard->entry.type = MHEARD_TYPE_REJ;
- mheard->entry.sframes++;
+ case PID_TEXNET:
+ mheard->entry.mode |= MHEARD_MODE_TEXNET;
break;
- case FRMR:
- mheard->entry.type = MHEARD_TYPE_FRMR;
- mheard->entry.uframes++;
+ case PID_FLEXNET:
+ mheard->entry.mode |= MHEARD_MODE_FLEXNET;
break;
- case I:
- mheard->entry.type = MHEARD_TYPE_I;
- mheard->entry.iframes++;
+ case PID_PSATPB:
+ mheard->entry.mode |= MHEARD_MODE_PSATPB;
break;
- case UI:
- mheard->entry.type = MHEARD_TYPE_UI;
- mheard->entry.uframes++;
+ case PID_PSATFT:
+ mheard->entry.mode |= MHEARD_MODE_PSATFT;
break;
default:
if (logging)
- syslog(LOG_WARNING, "unknown packet type %02X\n", *data);
- mheard->entry.type = MHEARD_TYPE_UNKNOWN;
+ syslog(LOG_WARNING, "unknown PID %02X\n", *data);
+ mheard->entry.mode |= MHEARD_MODE_UNKNOWN;
break;
- }
-
- data += ctlen;
- size -= ctlen;
-
- if (type == I || type == UI) {
- switch (*data) {
- case PID_TEXT:
- mheard->entry.mode |= MHEARD_MODE_TEXT;
- break;
- case PID_SEGMENT:
- mheard->entry.mode |= MHEARD_MODE_SEGMENT;
- break;
- case PID_ARP:
- mheard->entry.mode |= MHEARD_MODE_ARP;
- break;
- case PID_NETROM:
- mheard->entry.mode |= MHEARD_MODE_NETROM;
- break;
- case PID_IP:
- mheard->entry.mode |= (type == I) ? MHEARD_MODE_IP_VC : MHEARD_MODE_IP_DG;
- break;
- case PID_ROSE:
- mheard->entry.mode |= MHEARD_MODE_ROSE;
- break;
- case PID_TEXNET:
- mheard->entry.mode |= MHEARD_MODE_TEXNET;
- break;
- case PID_FLEXNET:
- mheard->entry.mode |= MHEARD_MODE_FLEXNET;
- break;
- case PID_PSATPB:
- mheard->entry.mode |= MHEARD_MODE_PSATPB;
- break;
- case PID_PSATFT:
- mheard->entry.mode |= MHEARD_MODE_PSATFT;
- break;
- default:
- if (logging)
- syslog(LOG_WARNING, "unknown PID %02X\n", *data);
- mheard->entry.mode |= MHEARD_MODE_UNKNOWN;
- break;
}
}
-
+
if (mheard->entry.first_heard == 0)
time(&mheard->entry.first_heard);
-
+
time(&mheard->entry.last_heard);
if ((fp = fopen(DATA_MHEARD_FILE, "r+")) == NULL) {
@@ -398,16 +398,16 @@ int main(int argc, char **argv)
syslog(LOG_ERR, "cannot open mheard data file\n");
continue;
}
-
+
if (mheard->position == 0xFFFFFF) {
fseek(fp, 0L, SEEK_END);
mheard->position = ftell(fp);
}
fseek(fp, mheard->position, SEEK_SET);
-
+
fwrite(&mheard->entry, sizeof(struct mheard_struct), 1, fp);
-
+
fclose(fp);
}
}
@@ -445,7 +445,7 @@ static struct mheard_list_struct *findentry(ax25_address *callsign, char *port)
{
struct mheard_list_struct *oldest = NULL;
int i;
-
+
for (i = 0; i < mheard_list_size; i++)
if (mheard_list[i].in_use &&
ax25_cmp(&mheard_list[i].entry.from_call, callsign) == 0 &&
@@ -475,4 +475,3 @@ static struct mheard_list_struct *findentry(ax25_address *callsign, char *port)
return oldest;
}
-
diff --git a/ax25/rxecho.c b/ax25/rxecho.c
index 7acb156..c67b95e 100644
--- a/ax25/rxecho.c
+++ b/ax25/rxecho.c
@@ -28,14 +28,14 @@
* callsign didn't match (and the frame wasn't echoed anywhere).
*
* *** 20021206 dl9sau:
- * - fixed a bug preventing echo to multible ports; it may also
+ * - fixed a bug preventing echo to multible ports; it may also
* lead to retransmission on the interface where it came from
* - fixed problem that frames via sendto(...,alen) had a wrong
* protocol (because alen became larger than the size of
* struct sockaddr).
* - sockaddr_pkt is the right struct for recvfrom/sendto on
* type SOCK_PACKET family AF_INET sockets.
- * - added support for new PF_PACKET family with sockaddr_ll
+ * - added support for new PF_PACKET family with sockaddr_ll
*
* ***
*
@@ -136,7 +136,7 @@ static void terminate(int sig)
syslog(LOG_INFO, "terminating on SIGTERM\n");
closelog();
}
-
+
exit(0);
}
@@ -238,7 +238,7 @@ static struct config *readconfig(void)
}
/*
- * Slightly modified from linux/include/net/ax25.h and
+ * Slightly modified from linux/include/net/ax25.h and
* linux/net/ax25/ax25_subr.c:
*/
@@ -264,13 +264,13 @@ typedef struct {
static unsigned char *ax25_parse_addr(unsigned char *buf, int len, ax25_address *src, ax25_address *dest, ax25_digi *digi)
{
int d = 0;
-
+
if (len < 14) return NULL;
-
+
#if 0
if (flags != NULL) {
*flags = 0;
-
+
if (buf[6] & LAPB_C) {
*flags = C_COMMAND;
}
@@ -279,16 +279,16 @@ static unsigned char *ax25_parse_addr(unsigned char *buf, int len, ax25_address
*flags = C_RESPONSE;
}
}
-
- if (dama != NULL)
+
+ if (dama != NULL)
*dama = ~buf[13] & DAMA_FLAG;
#endif
-
+
/* Copy to, from */
- if (dest != NULL)
+ if (dest != NULL)
memcpy(dest, buf + 0, AX25_ADDR_LEN);
- if (src != NULL)
+ if (src != NULL)
memcpy(src, buf + 7, AX25_ADDR_LEN);
buf += 2 * AX25_ADDR_LEN;
@@ -296,7 +296,7 @@ static unsigned char *ax25_parse_addr(unsigned char *buf, int len, ax25_address
digi->lastrepeat = -1;
digi->ndigi = 0;
-
+
while (!(buf[-1] & LAPB_E)) {
if (d >= AX25_MAX_DIGIS) return NULL; /* Max of 6 digis */
if (len < 7) return NULL; /* Short packet */
@@ -382,15 +382,15 @@ int main(int argc, char **argv)
while ((s = getopt(argc, argv, "lv")) != -1) {
switch (s) {
- case 'l':
- logging = TRUE;
- break;
- case 'v':
- printf("rxecho: %s\n", VERSION);
- return 0;
- default:
- fprintf(stderr, "usage: rxecho [-l] [-v]\n");
- return 1;
+ case 'l':
+ logging = TRUE;
+ break;
+ case 'v':
+ printf("rxecho: %s\n", VERSION);
+ return 0;
+ default:
+ fprintf(stderr, "usage: rxecho [-l] [-v]\n");
+ return 1;
}
}
@@ -455,7 +455,7 @@ int main(int argc, char **argv)
}
for (;;) {
- alen = sa_len;
+ alen = sa_len;
if ((size = recvfrom(s, buf, 1500, 0, psa, &alen)) == -1) {
if (logging) {
@@ -479,11 +479,11 @@ int main(int argc, char **argv)
for (p = list; p != NULL; p = p->next)
#ifdef USE_SOCKADDR_SLL
- if (p->from_idx == from_idx && (check_calls(p, buf, size) == 0)) {
- sll.sll_ifindex = p->to_idx;
+ if (p->from_idx == from_idx && (check_calls(p, buf, size) == 0)) {
+ sll.sll_ifindex = p->to_idx;
#else
- if ((strcmp(p->from, from_dev_name) == 0) && (check_calls(p, buf, size) == 0)) {
- strcpy(psa->sa_data, p->to);
+ if ((strcmp(p->from, from_dev_name) == 0) && (check_calls(p, buf, size) == 0)) {
+ strcpy(psa->sa_data, p->to);
#endif
/*
* cave: alen (set by recvfrom()) may > salen