diff options
author | Phil Blundell <philb@gnu.org> | 1998-04-10 21:53:32 +0000 |
---|---|---|
committer | Phil Blundell <philb@gnu.org> | 1998-04-10 21:53:32 +0000 |
commit | db2c3153948427da038d69dd7c83a93f0c8ac6b5 (patch) | |
tree | 342bf0a6622b5396fbbda7943ed73c1a2f871330 /lib/econet.c | |
parent | Update for new kernel, plus more changes. (diff) | |
download | net-tools-db2c3153948427da038d69dd7c83a93f0c8ac6b5.tar.gz net-tools-db2c3153948427da038d69dd7c83a93f0c8ac6b5.tar.bz2 net-tools-db2c3153948427da038d69dd7c83a93f0c8ac6b5.zip |
Pile of net-tools goodies. I plan to make a 1.45 release this
weekend - please give it a go and make sure it at least compiles
on your system. :-)
Diffstat (limited to 'lib/econet.c')
-rw-r--r-- | lib/econet.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/lib/econet.c b/lib/econet.c new file mode 100644 index 0000000..6211fc5 --- /dev/null +++ b/lib/econet.c @@ -0,0 +1,87 @@ +/* + * lib/econet.c This file contains an implementation of the Econet + * support functions for the net-tools. + * (NET-3 base distribution). + * + * Version: lib/econet.c 1.00 1998-04-10 + * + * Author: Philip Blundell <philb@gnu.org> + * + * Modified: + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at + * your option) any later version. + */ + +#include "config.h" + +#if HAVE_AFECONET + +#include <sys/types.h> +#include <sys/socket.h> +#include <stdio.h> + +#include "version.h" +#include "net-support.h" +#include "pathnames.h" + +#define EXTERN +#include "net-locale.h" + +#include <linux/if_ec.h> + +/* Display an Econet address */ +static char * +ec_print(unsigned char *ptr) +{ + static char buff[64]; + struct ec_addr *ec = (struct ec_addr *)ptr; + sprintf(buff,"%d.%d", ec->net, ec->station); + return buff; +} + + +/* Display an Econet socket address */ +static char * +ec_sprint(struct sockaddr *sap, int numeric) +{ + static char buf[64]; + struct sockaddr_ec *sec = (struct sockaddr_ec *)sap; + + if (sap->sa_family != AF_ECONET) + return(NLS_CATBUFF (catfd, ecSet, ec_none, "[NONE SET]", buf, 64)); + + return ec_print((unsigned char *)&sec->addr); +} + +static int +ec_input(int type, char *bufp, struct sockaddr *sap) +{ + struct sockaddr_ec *sec = (struct sockaddr_ec *)sap; + int net, stn; + switch (sscanf(bufp, "%d.%d", &net, &stn)) + { + case 2: + sec->addr.station = stn; + sec->addr.net = net; + return 0; + case 1: + if (sscanf(bufp, "%d", &stn) == 1) { + sec->addr.net = 0; + sec->addr.station = stn; + return 0; + } + } + return -1; +} + +struct aftype ec_aftype = { + "ec", NULL, AF_ECONET, 0, + ec_print, ec_sprint, ec_input, NULL, + NULL +}; + +#endif /* HAVE_AFECONET */ |