From f76e0b330f0be28f9f3af3073904ede3a34d48f5 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 5 Jun 2013 15:34:56 +0200 Subject: Reformat consistently. Strictly whitespace changes only. Indentation by tabs only. Move case labels in switches are on the same level as the switch keyword. Signed-off-by: Ralf Baechle --- ax25/access.c | 34 +- ax25/access.h | 8 +- ax25/ax25d.c | 770 +++++++++++++++++++++--------------------- ax25/axgetput/axgetput.c | 536 ++++++++++++++--------------- ax25/axgetput/proto_bin.c | 838 +++++++++++++++++++++++----------------------- ax25/axparms.c | 22 +- ax25/axspawn.c | 472 +++++++++++++------------- ax25/beacon.c | 58 ++-- ax25/bpqparms.c | 72 ++-- ax25/md5.c | 274 +++++++-------- ax25/md5.h | 8 +- ax25/mheard.c | 262 +++++++-------- ax25/mheardd.c | 226 ++++++------- ax25/rxecho.c | 22 +- 14 files changed, 1801 insertions(+), 1801 deletions(-) (limited to 'ax25') diff --git a/ax25/access.c b/ax25/access.c index 185deda..5a588db 100644 --- a/ax25/access.c +++ b/ax25/access.c @@ -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]; + } } /*--------------------------------------------------------------------------*/ diff --git a/ax25/access.h b/ax25/access.h index d54339d..8859262 100644 --- a/ax25/access.h +++ b/ax25/access.h @@ -8,10 +8,10 @@ #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); diff --git a/ax25/ax25d.c b/ax25/ax25d.c index 5135e1d..4d7007a 100644 --- a/ax25/ax25d.c +++ b/ax25/ax25d.c @@ -268,21 +268,21 @@ int main(int argc, char *argv[]) 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; } } @@ -372,18 +372,18 @@ int main(int argc, char *argv[]) } 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); - - 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); + /* + * 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); + exit(1); - default: - close(new); - break; + default: + close(new); + break; } } } @@ -676,72 +676,72 @@ static void WorkoutArgs(int af_type, char *shell, int *argc, char **argv) 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; + 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; @@ -831,31 +831,31 @@ static int ReadConfig(void) 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; + 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) { @@ -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; } } diff --git a/ax25/axgetput/axgetput.c b/ax25/axgetput/axgetput.c index dc077c5..de21bc5 100644 --- a/ax25/axgetput/axgetput.c +++ b/ax25/axgetput/axgetput.c @@ -52,92 +52,92 @@ static mode_t mode_tty; 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; + 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 ] [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 ] [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,190 +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 78a6ccc..55b836a 100644 --- a/ax25/axgetput/proto_bin.c +++ b/ax25/axgetput/proto_bin.c @@ -11,34 +11,34 @@ #include "util.h" static int crctab[256]; -static int bittab[8] = { 128,64,32,16,8,4,2,1 }; +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 ((bittab[j] & i) != 0) { + crctab[i] = crctab[i] ^ crcbit[j]; + } + } + } + return 0; } /*---------------------------------------------------------------------------*/ static int do_crc(char b, int n, unsigned int crc) { - crc = (crctab[(crc >> 8)] ^ ((crc << 8) | (b & 0xff))) & 0xffff; - return crc; + crc = (crctab[(crc >> 8)] ^ ((crc << 8) | (b & 0xff))) & 0xffff; + return crc; } /*---------------------------------------------------------------------------*/ @@ -46,11 +46,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 +58,450 @@ 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: received. not 8bit clean?\r"; - secure_write(fdout, p, strlen(p)); + p = "warning: received. not 8bit clean?\r"; + secure_write(fdout, p, strlen(p)); #endif - sprintf(err_msg, "bad EOL: \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: \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 (term_line && len == len_termline && !memcmp(buf, term_line, len_termline)) { - /* sucessfully read until termination string */ - break; + + 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); } - } - 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; + + /* 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; + } + 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 (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; 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; \ + 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) { + 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 0 - char *p = "warning: received. not 8bit clean?\r"; - secure_write(fdout, p, strlen(p)); + char *p = "warning: received. not 8bit clean?\r"; + secure_write(fdout, p, strlen(p)); #endif - sprintf(err_msg, "bad EOL: \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; + sprintf(err_msg, "bad EOL: \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; } - 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; + + 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/axparms.c b/ax25/axparms.c index 1f1f6ca..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) diff --git a/ax25/axspawn.c b/ax25/axspawn.c index 34c2598..e3d6bd8 100644 --- a/ax25/axspawn.c +++ b/ax25/axspawn.c @@ -218,212 +218,212 @@ 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 }; @@ -671,7 +671,7 @@ 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; } @@ -879,7 +879,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); @@ -888,7 +888,7 @@ int write_ax25(char *s, int len, int kick) tcsetattr(0, TCSANOW, &save_termios); last_ended_with_CR = 0; return 0; - } + } if (!bin) { @@ -1137,16 +1137,16 @@ end_mkdirs: char *opt_shell = ""; struct stat statbuf; if (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. - */ - opt_shell = " -s \"/bin/sh\""; + /* 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. + */ + opt_shell = " -s \"/bin/sh\""; } sprintf(command,"/usr/sbin/useradd -p \"%s\" -c %s -d %s -u %d -g %d -m %s%s", ((policy_add_empty_password) ? "" : "+"), @@ -1418,27 +1418,27 @@ int main(int argc, char **argv) } 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++) @@ -1637,13 +1637,13 @@ 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); diff --git a/ax25/beacon.c b/ax25/beacon.c index 26d1998..ca229c7 100644 --- a/ax25/beacon.c +++ b/ax25/beacon.c @@ -40,35 +40,35 @@ int main(int argc, char *argv[]) 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 ] [-d ] [-l] [-m] [-s] [-t interval] [-v] \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 ] [-d ] [-l] [-m] [-s] [-t interval] [-v] \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); diff --git a/ax25/bpqparms.c b/ax25/bpqparms.c index 590ab61..83734a8 100644 --- a/ax25/bpqparms.c +++ b/ax25/bpqparms.c @@ -79,42 +79,42 @@ 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(); } } 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 c2f2013..2370a46 100644 --- a/ax25/mheard.c +++ b/ax25/mheard.c @@ -40,18 +40,18 @@ 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); + 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, 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, 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; } } @@ -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 '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 's': + data = 2; 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]); + 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 'p': + mode = 1; + break; + 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.c b/ax25/mheardd.c index 40eab3b..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; } } @@ -294,97 +294,97 @@ 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; } } diff --git a/ax25/rxecho.c b/ax25/rxecho.c index ab862bb..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 * * *** * @@ -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; } } -- cgit v1.2.3