linux-decnet-commit Mailing List for DECnet for Linux (Page 31)
Brought to you by:
chrissie_c,
ph3-der-loewe
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(15) |
Nov
(16) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(20) |
Feb
(27) |
Mar
(25) |
Apr
(12) |
May
(2) |
Jun
(6) |
Jul
(36) |
Aug
(12) |
Sep
(12) |
Oct
(16) |
Nov
(5) |
Dec
(5) |
2003 |
Jan
(8) |
Feb
(9) |
Mar
(25) |
Apr
(18) |
May
(29) |
Jun
(4) |
Jul
(1) |
Aug
|
Sep
(10) |
Oct
(5) |
Nov
(3) |
Dec
(9) |
2004 |
Jan
(17) |
Feb
|
Mar
(9) |
Apr
|
May
(4) |
Jun
(1) |
Jul
(2) |
Aug
(21) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2005 |
Jan
(5) |
Feb
|
Mar
(13) |
Apr
|
May
(3) |
Jun
(1) |
Jul
|
Aug
|
Sep
(13) |
Oct
(83) |
Nov
(2) |
Dec
|
2006 |
Jan
(21) |
Feb
(1) |
Mar
(32) |
Apr
(31) |
May
(3) |
Jun
(1) |
Jul
|
Aug
(7) |
Sep
|
Oct
(1) |
Nov
(3) |
Dec
(13) |
2007 |
Jan
(1) |
Feb
(7) |
Mar
|
Apr
(2) |
May
|
Jun
(1) |
Jul
(2) |
Aug
(20) |
Sep
|
Oct
|
Nov
|
Dec
(7) |
2008 |
Jan
(4) |
Feb
(13) |
Mar
(24) |
Apr
(18) |
May
(10) |
Jun
|
Jul
|
Aug
(40) |
Sep
(72) |
Oct
(61) |
Nov
(9) |
Dec
(2) |
2009 |
Jan
(6) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(7) |
Jul
|
Aug
|
Sep
|
Oct
(8) |
Nov
|
Dec
(3) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
(5) |
May
|
Jun
|
Jul
(41) |
Aug
(28) |
Sep
(2) |
Oct
(5) |
Nov
(4) |
Dec
|
2011 |
Jan
(7) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Patrick C. <pa...@us...> - 2003-05-04 12:04:52
|
Update of /cvsroot/linux-decnet/dnprogs/dnroute In directory sc8-pr-cvs1:/tmp/cvs-serv8024 Modified Files: Makefile Added Files: dnroute.8 Log Message: Basic manpage. add make install to Makefile --- NEW FILE: dnroute.8 --- .TH DNROUTE 8 "May 4 2003" "DECnet utilities" .SH NAME dnroute \- DECnet Routing Daemon .SH SYNOPSIS .B dnroute [options] .br Options: .br [\-dvVhr] .SH DESCRIPTION .PP .B dnroute is a daemon that manages the DECnet routing tables to provide a simple routing policy. .br .B dnetd reads polls the DECnet neighbour table and copies those entries into the internal routing tables, thus providing a simple (I can see that node, therefore I can route to it) routing system. For many sites this will be simple enough. it is still possible to add routes using the ip(8) command. .SH OPTIONS .TP .I "\-d" Don't fork and run the background. Use this for debugging. .TP .I "\-v" Verbose. The more of these there are the more verbose droute will be. .TP .I \-h \-? Displays help for using the command. .TP .I \-r Send DECnet routing messages showing the routes set by the daemon. .TP .I \-l Listen to incoming routing messages and add routes based on that information (not currently implemted) .TP .I \-V Show the version of dnroute. .SH SEE ALSO .BR dnetd.conf "(5), " ip "(8)" Index: Makefile =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnroute/Makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** Makefile 4 May 2003 11:53:30 -0000 1.4 --- Makefile 4 May 2003 12:04:48 -0000 1.5 *************** *** 13,16 **** --- 13,22 ---- $(MAKE) -C netlink + install: + install -d $(prefix)/sbin + install -d $(prefix)/man/man8 + install -m 0755 -s dnroute $(prefix)/sbin + install -m 0644 dnroute.8 $(prefix)/man/man8 + clean: rm -f $(DNROUTE) *~ *.o netlink/*.o netlink/*.a |
From: Patrick C. <pa...@us...> - 2003-05-04 11:56:52
|
Update of /cvsroot/linux-decnet/dnprogs In directory sc8-pr-cvs1:/tmp/cvs-serv4936 Modified Files: Makefile README Log Message: add dnroute to the makefile list update README Index: Makefile =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/Makefile,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** Makefile 13 Sep 2002 10:50:35 -0000 1.18 --- Makefile 4 May 2003 11:56:48 -0000 1.19 *************** *** 9,13 **** SUBDIRS=include libdnet libdaemon libdap librms fal dndir dnsubmit dndel \ ! dncopy apps dntask mail phone dnetd scripts all: --- 9,13 ---- SUBDIRS=include libdnet libdaemon libdap librms fal dndir dnsubmit dndel \ ! dncopy apps dntask mail phone dnetd dnroute scripts all: Index: README =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/README,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** README 18 Oct 2002 09:52:51 -0000 1.6 --- README 4 May 2003 11:56:49 -0000 1.7 *************** *** 187,191 **** I have supplied it here pre-configured for Linux and it seems OK for me on ! libc5 and 6 systems, Intel, SPARC and Alpha. If you have problems or you want the rest of the uudeview distribution or want --- 187,191 ---- I have supplied it here pre-configured for Linux and it seems OK for me on ! libc5 and 6 systems of various architectures. If you have problems or you want the rest of the uudeview distribution or want *************** *** 227,233 **** ------- These programs have been tested on Linux 2.0, 2.1, 2.2, 2.3 & 2.4 on Intel, ! Alpha and SPARC machines (though not necessarily all combinations!) userland ! compiles on HPPA machines but there seems to be a kernel problem with that ! architecture at the moment. I encourage all users to join the linux-decnet mailing list by visiting the --- 227,231 ---- ------- These programs have been tested on Linux 2.0, 2.1, 2.2, 2.3 & 2.4 on Intel, ! Alpha, SPARC and parisc machines (though not necessarily all combinations!). I encourage all users to join the linux-decnet mailing list by visiting the |
From: Patrick C. <pa...@us...> - 2003-05-04 11:55:39
|
Update of /cvsroot/linux-decnet/dnprogs/dnroute In directory sc8-pr-cvs1:/tmp/cvs-serv4619 Added Files: TODO Log Message: Things to do --- NEW FILE: TODO --- - Remove dead routes - Add routes based on incoming routing messages - Check outgoing routing messages are still correct |
From: Patrick C. <pa...@us...> - 2003-05-04 11:53:35
|
Update of /cvsroot/linux-decnet/dnprogs/dnroute/netlink In directory sc8-pr-cvs1:/tmp/cvs-serv3636/netlink Added Files: Makefile libnetlink.c ll_map.c Log Message: Fix routing messages incorporate as much of iproute2 as we need into the tree. --- NEW FILE: Makefile --- NLOBJ=ll_map.o libnetlink.o CFLAGS+=-Iinclude all: libnetlink.a # libutil.a libnetlink.a: $(NLOBJ) ar rcs $@ $(NLOBJ) clean: rm -f $(NLOBJ) $(ADDLIB) libnetlink.a --- NEW FILE: libnetlink.c --- /* * libnetlink.c RTnetlink service routines. * * 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. * * Authors: Alexey Kuznetsov, <ku...@ms...> * */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <syslog.h> #include <fcntl.h> #include <net/if_arp.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include <errno.h> #include <time.h> #include <sys/uio.h> #include "libnetlink.h" void rtnl_close(struct rtnl_handle *rth) { close(rth->fd); } int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions) { int addr_len; memset(rth, 0, sizeof(rth)); rth->fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (rth->fd < 0) { perror("Cannot open netlink socket"); return -1; } memset(&rth->local, 0, sizeof(rth->local)); rth->local.nl_family = AF_NETLINK; rth->local.nl_groups = subscriptions; if (bind(rth->fd, (struct sockaddr*)&rth->local, sizeof(rth->local)) < 0) { perror("Cannot bind netlink socket"); return -1; } addr_len = sizeof(rth->local); if (getsockname(rth->fd, (struct sockaddr*)&rth->local, &addr_len) < 0) { perror("Cannot getsockname"); return -1; } if (addr_len != sizeof(rth->local)) { fprintf(stderr, "Wrong address length %d\n", addr_len); return -1; } if (rth->local.nl_family != AF_NETLINK) { fprintf(stderr, "Wrong address family %d\n", rth->local.nl_family); return -1; } rth->seq = time(NULL); return 0; } int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type) { struct { struct nlmsghdr nlh; struct rtgenmsg g; } req; struct sockaddr_nl nladdr; memset(&nladdr, 0, sizeof(nladdr)); nladdr.nl_family = AF_NETLINK; req.nlh.nlmsg_len = sizeof(req); req.nlh.nlmsg_type = type; req.nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST; req.nlh.nlmsg_pid = 0; req.nlh.nlmsg_seq = rth->dump = ++rth->seq; req.g.rtgen_family = family; return sendto(rth->fd, (void*)&req, sizeof(req), 0, (struct sockaddr*)&nladdr, sizeof(nladdr)); } int rtnl_send(struct rtnl_handle *rth, char *buf, int len) { struct sockaddr_nl nladdr; memset(&nladdr, 0, sizeof(nladdr)); nladdr.nl_family = AF_NETLINK; return sendto(rth->fd, buf, len, 0, (struct sockaddr*)&nladdr, sizeof(nladdr)); } int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len) { struct nlmsghdr nlh; struct sockaddr_nl nladdr; struct iovec iov[2] = { { &nlh, sizeof(nlh) }, { req, len } }; struct msghdr msg = { (void*)&nladdr, sizeof(nladdr), iov, 2, NULL, 0, 0 }; memset(&nladdr, 0, sizeof(nladdr)); nladdr.nl_family = AF_NETLINK; nlh.nlmsg_len = NLMSG_LENGTH(len); nlh.nlmsg_type = type; nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST; nlh.nlmsg_pid = 0; nlh.nlmsg_seq = rth->dump = ++rth->seq; return sendmsg(rth->fd, &msg, 0); } int rtnl_dump_filter(struct rtnl_handle *rth, int (*filter)(struct sockaddr_nl *, struct nlmsghdr *n, void *), void *arg1, int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *), void *arg2) { char buf[8192]; struct sockaddr_nl nladdr; struct iovec iov = { buf, sizeof(buf) }; while (1) { int status; struct nlmsghdr *h; struct msghdr msg = { (void*)&nladdr, sizeof(nladdr), &iov, 1, NULL, 0, 0 }; status = recvmsg(rth->fd, &msg, 0); if (status < 0) { if (errno == EINTR) continue; perror("OVERRUN"); continue; } if (status == 0) { fprintf(stderr, "EOF on netlink\n"); return -1; } if (msg.msg_namelen != sizeof(nladdr)) { fprintf(stderr, "sender address length == %d\n", msg.msg_namelen); exit(1); } h = (struct nlmsghdr*)buf; while (NLMSG_OK(h, status)) { int err; if (h->nlmsg_pid != rth->local.nl_pid || h->nlmsg_seq != rth->dump) { if (junk) { err = junk(&nladdr, h, arg2); if (err < 0) return err; } goto skip_it; } if (h->nlmsg_type == NLMSG_DONE) return 0; if (h->nlmsg_type == NLMSG_ERROR) { struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h); if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) { fprintf(stderr, "ERROR truncated\n"); } else { errno = -err->error; perror("RTNETLINK answers"); } return -1; } err = filter(&nladdr, h, arg1); if (err < 0) return err; skip_it: h = NLMSG_NEXT(h, status); } if (msg.msg_flags & MSG_TRUNC) { fprintf(stderr, "Message truncated\n"); continue; } if (status) { fprintf(stderr, "!!!Remnant of size %d\n", status); exit(1); } } } int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, unsigned groups, struct nlmsghdr *answer, int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *), void *jarg) { int status; unsigned seq; struct nlmsghdr *h; struct sockaddr_nl nladdr; struct iovec iov = { (void*)n, n->nlmsg_len }; char buf[8192]; struct msghdr msg = { (void*)&nladdr, sizeof(nladdr), &iov, 1, NULL, 0, 0 }; memset(&nladdr, 0, sizeof(nladdr)); nladdr.nl_family = AF_NETLINK; nladdr.nl_pid = peer; nladdr.nl_groups = groups; n->nlmsg_seq = seq = ++rtnl->seq; if (answer == NULL) n->nlmsg_flags |= NLM_F_ACK; status = sendmsg(rtnl->fd, &msg, 0); if (status < 0) { perror("Cannot talk to rtnetlink"); return -1; } iov.iov_base = buf; while (1) { iov.iov_len = sizeof(buf); status = recvmsg(rtnl->fd, &msg, 0); if (status < 0) { if (errno == EINTR) continue; perror("OVERRUN"); continue; } if (status == 0) { fprintf(stderr, "EOF on netlink\n"); return -1; } if (msg.msg_namelen != sizeof(nladdr)) { fprintf(stderr, "sender address length == %d\n", msg.msg_namelen); exit(1); } for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) { int err; int len = h->nlmsg_len; int l = len - sizeof(*h); if (l<0 || len>status) { if (msg.msg_flags & MSG_TRUNC) { fprintf(stderr, "Truncated message\n"); return -1; } fprintf(stderr, "!!!malformed message: len=%d\n", len); exit(1); } if (h->nlmsg_pid != rtnl->local.nl_pid || h->nlmsg_seq != seq) { if (junk) { err = junk(&nladdr, h, jarg); if (err < 0) return err; } continue; } if (h->nlmsg_type == NLMSG_ERROR) { struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h); if (l < sizeof(struct nlmsgerr)) { fprintf(stderr, "ERROR truncated\n"); } else { errno = -err->error; if (errno == 0) { if (answer) memcpy(answer, h, h->nlmsg_len); return 0; } perror("RTNETLINK answers"); } return -1; } if (answer) { memcpy(answer, h, h->nlmsg_len); return 0; } fprintf(stderr, "Unexpected reply!!!\n"); status -= NLMSG_ALIGN(len); h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); } if (msg.msg_flags & MSG_TRUNC) { fprintf(stderr, "Message truncated\n"); continue; } if (status) { fprintf(stderr, "!!!Remnant of size %d\n", status); exit(1); } } } int rtnl_listen(struct rtnl_handle *rtnl, int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *), void *jarg) { int status; struct nlmsghdr *h; struct sockaddr_nl nladdr; struct iovec iov; char buf[8192]; struct msghdr msg = { (void*)&nladdr, sizeof(nladdr), &iov, 1, NULL, 0, 0 }; memset(&nladdr, 0, sizeof(nladdr)); nladdr.nl_family = AF_NETLINK; nladdr.nl_pid = 0; nladdr.nl_groups = 0; iov.iov_base = buf; while (1) { iov.iov_len = sizeof(buf); status = recvmsg(rtnl->fd, &msg, 0); if (status < 0) { if (errno == EINTR) continue; perror("OVERRUN"); continue; } if (status == 0) { fprintf(stderr, "EOF on netlink\n"); return -1; } if (msg.msg_namelen != sizeof(nladdr)) { fprintf(stderr, "Sender address length == %d\n", msg.msg_namelen); exit(1); } for (h = (struct nlmsghdr*)buf; status >= sizeof(*h); ) { int err; int len = h->nlmsg_len; int l = len - sizeof(*h); if (l<0 || len>status) { if (msg.msg_flags & MSG_TRUNC) { fprintf(stderr, "Truncated message\n"); return -1; } fprintf(stderr, "!!!malformed message: len=%d\n", len); exit(1); } err = handler(&nladdr, h, jarg); if (err < 0) return err; status -= NLMSG_ALIGN(len); h = (struct nlmsghdr*)((char*)h + NLMSG_ALIGN(len)); } if (msg.msg_flags & MSG_TRUNC) { fprintf(stderr, "Message truncated\n"); continue; } if (status) { fprintf(stderr, "!!!Remnant of size %d\n", status); exit(1); } } } int rtnl_from_file(FILE *rtnl, int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *), void *jarg) { int status; struct sockaddr_nl nladdr; char buf[8192]; struct nlmsghdr *h = (void*)buf; memset(&nladdr, 0, sizeof(nladdr)); nladdr.nl_family = AF_NETLINK; nladdr.nl_pid = 0; nladdr.nl_groups = 0; while (1) { int err, len, type; int l; status = fread(&buf, 1, sizeof(*h), rtnl); if (status < 0) { if (errno == EINTR) continue; perror("rtnl_from_file: fread"); return -1; } if (status == 0) return 0; len = h->nlmsg_len; type= h->nlmsg_type; l = len - sizeof(*h); if (l<0 || len>sizeof(buf)) { fprintf(stderr, "!!!malformed message: len=%d @%lu\n", len, ftell(rtnl)); return -1; } status = fread(NLMSG_DATA(h), 1, NLMSG_ALIGN(l), rtnl); if (status < 0) { perror("rtnl_from_file: fread"); return -1; } if (status < l) { fprintf(stderr, "rtnl-from_file: truncated message\n"); return -1; } err = handler(&nladdr, h, jarg); if (err < 0) return err; } } int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data) { int len = RTA_LENGTH(4); struct rtattr *rta; if (NLMSG_ALIGN(n->nlmsg_len) + len > maxlen) return -1; rta = (struct rtattr*)(((char*)n) + NLMSG_ALIGN(n->nlmsg_len)); rta->rta_type = type; rta->rta_len = len; memcpy(RTA_DATA(rta), &data, 4); n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + len; return 0; } int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen) { int len = RTA_LENGTH(alen); struct rtattr *rta; if (NLMSG_ALIGN(n->nlmsg_len) + len > maxlen) return -1; rta = (struct rtattr*)(((char*)n) + NLMSG_ALIGN(n->nlmsg_len)); rta->rta_type = type; rta->rta_len = len; memcpy(RTA_DATA(rta), data, alen); n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + len; return 0; } int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data) { int len = RTA_LENGTH(4); struct rtattr *subrta; if (RTA_ALIGN(rta->rta_len) + len > maxlen) return -1; subrta = (struct rtattr*)(((char*)rta) + RTA_ALIGN(rta->rta_len)); subrta->rta_type = type; subrta->rta_len = len; memcpy(RTA_DATA(subrta), &data, 4); rta->rta_len = NLMSG_ALIGN(rta->rta_len) + len; return 0; } int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen) { struct rtattr *subrta; int len = RTA_LENGTH(alen); if (RTA_ALIGN(rta->rta_len) + len > maxlen) return -1; subrta = (struct rtattr*)(((char*)rta) + RTA_ALIGN(rta->rta_len)); subrta->rta_type = type; subrta->rta_len = len; memcpy(RTA_DATA(subrta), data, alen); rta->rta_len = NLMSG_ALIGN(rta->rta_len) + len; return 0; } int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) { while (RTA_OK(rta, len)) { if (rta->rta_type <= max) tb[rta->rta_type] = rta; rta = RTA_NEXT(rta,len); } if (len) fprintf(stderr, "!!!Deficit %d, rta_len=%d\n", len, rta->rta_len); return 0; } --- NEW FILE: ll_map.c --- /* * ll_map.c * * 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. * * Authors: Alexey Kuznetsov, <ku...@ms...> * */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <syslog.h> #include <fcntl.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include "libnetlink.h" #include "ll_map.h" struct idxmap { struct idxmap * next; int index; int type; int alen; unsigned flags; unsigned char addr[8]; char name[16]; }; static struct idxmap *idxmap[16]; int ll_remember_index(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) { int h; struct ifinfomsg *ifi = NLMSG_DATA(n); struct idxmap *im, **imp; struct rtattr *tb[IFLA_MAX+1]; if (n->nlmsg_type != RTM_NEWLINK) return 0; if (n->nlmsg_len < NLMSG_LENGTH(sizeof(ifi))) return -1; memset(tb, 0, sizeof(tb)); parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), IFLA_PAYLOAD(n)); if (tb[IFLA_IFNAME] == NULL) return 0; h = ifi->ifi_index&0xF; for (imp=&idxmap[h]; (im=*imp)!=NULL; imp = &im->next) if (im->index == ifi->ifi_index) break; if (im == NULL) { im = malloc(sizeof(*im)); if (im == NULL) return 0; im->next = *imp; im->index = ifi->ifi_index; *imp = im; } im->type = ifi->ifi_type; im->flags = ifi->ifi_flags; if (tb[IFLA_ADDRESS]) { int alen; im->alen = alen = RTA_PAYLOAD(tb[IFLA_ADDRESS]); if (alen > sizeof(im->addr)) alen = sizeof(im->addr); memcpy(im->addr, RTA_DATA(tb[IFLA_ADDRESS]), alen); } else { im->alen = 0; memset(im->addr, 0, sizeof(im->addr)); } strcpy(im->name, RTA_DATA(tb[IFLA_IFNAME])); return 0; } const char *ll_idx_n2a(int idx, char *buf) { struct idxmap *im; if (idx == 0) return "*"; for (im = idxmap[idx&0xF]; im; im = im->next) if (im->index == idx) return im->name; snprintf(buf, 16, "if%d", idx); return buf; } const char *ll_index_to_name(int idx) { static char nbuf[16]; return ll_idx_n2a(idx, nbuf); } int ll_index_to_type(int idx) { struct idxmap *im; if (idx == 0) return -1; for (im = idxmap[idx&0xF]; im; im = im->next) if (im->index == idx) return im->type; return -1; } unsigned ll_index_to_flags(int idx) { struct idxmap *im; if (idx == 0) return 0; for (im = idxmap[idx&0xF]; im; im = im->next) if (im->index == idx) return im->flags; return 0; } int ll_name_to_index(char *name) { static char ncache[16]; static int icache; struct idxmap *im; int i; if (name == NULL) return 0; if (icache && strcmp(name, ncache) == 0) return icache; for (i=0; i<16; i++) { for (im = idxmap[i]; im; im = im->next) { if (strcmp(im->name, name) == 0) { icache = im->index; strcpy(ncache, name); return im->index; } } } return 0; } int ll_init_map(struct rtnl_handle *rth) { if (rtnl_wilddump_request(rth, AF_UNSPEC, RTM_GETLINK) < 0) { perror("Cannot send dump request"); exit(1); } if (rtnl_dump_filter(rth, ll_remember_index, &idxmap, NULL, NULL) < 0) { fprintf(stderr, "Dump terminated\n"); exit(1); } return 0; } |
From: Patrick C. <pa...@us...> - 2003-05-04 11:53:35
|
Update of /cvsroot/linux-decnet/dnprogs/dnroute/netlink/include In directory sc8-pr-cvs1:/tmp/cvs-serv3636/netlink/include Added Files: SNAPSHOT.h libnetlink.h ll_map.h rt_names.h rtm_map.h utils.h Log Message: Fix routing messages incorporate as much of iproute2 as we need into the tree. --- NEW FILE: SNAPSHOT.h --- static char SNAPSHOT[] = "010824"; --- NEW FILE: libnetlink.h --- #ifndef __LIBNETLINK_H__ #define __LIBNETLINK_H__ 1 #include <asm/types.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> struct rtnl_handle { int fd; struct sockaddr_nl local; struct sockaddr_nl peer; __u32 seq; __u32 dump; }; extern int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions); extern void rtnl_close(struct rtnl_handle *rth); extern int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type); extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len); extern int rtnl_dump_filter(struct rtnl_handle *rth, int (*filter)(struct sockaddr_nl *, struct nlmsghdr *n, void *), void *arg1, int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *), void *arg2); extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, unsigned groups, struct nlmsghdr *answer, int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *), void *jarg); extern int rtnl_send(struct rtnl_handle *rth, char *buf, int); extern int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data); extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen); extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data); extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen); extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len); extern int rtnl_listen(struct rtnl_handle *, int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *), void *jarg); extern int rtnl_from_file(FILE *, int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *), void *jarg); #endif /* __LIBNETLINK_H__ */ --- NEW FILE: ll_map.h --- #ifndef __LL_MAP_H__ #define __LL_MAP_H__ 1 extern int ll_remember_index(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg); extern int ll_init_map(struct rtnl_handle *rth); extern int ll_name_to_index(char *name); extern const char *ll_index_to_name(int idx); extern const char *ll_idx_n2a(int idx, char *buf); extern int ll_index_to_type(int idx); extern unsigned ll_index_to_flags(int idx); #endif /* __LL_MAP_H__ */ --- NEW FILE: rt_names.h --- #ifndef RT_NAMES_H_ #define RT_NAMES_H_ 1 const char* rtnl_rtprot_n2a(int id, char *buf, int len); const char* rtnl_rtscope_n2a(int id, char *buf, int len); const char* rtnl_rttable_n2a(int id, char *buf, int len); const char* rtnl_rtrealm_n2a(int id, char *buf, int len); const char* rtnl_dsfield_n2a(int id, char *buf, int len); int rtnl_rtprot_a2n(int *id, char *arg); int rtnl_rtscope_a2n(int *id, char *arg); int rtnl_rttable_a2n(int *id, char *arg); int rtnl_rtrealm_a2n(__u32 *id, char *arg); int rtnl_dsfield_a2n(__u32 *id, char *arg); const char *inet_proto_n2a(int proto, char *buf, int len); int inet_proto_a2n(char *buf); const char * ll_type_n2a(int type, char *buf, int len); const char *ll_addr_n2a(unsigned char *addr, int alen, int type, char *buf, int blen); int ll_addr_a2n(unsigned char *lladdr, int len, char *arg); const char * ll_proto_n2a(unsigned short id, char *buf, int len); int ll_proto_a2n(unsigned short *id, char *buf); #endif --- NEW FILE: rtm_map.h --- #ifndef __RTM_MAP_H__ #define __RTM_MAP_H__ 1 char *rtnl_rtntype_n2a(int id, char *buf, int len); int rtnl_rtntype_a2n(int *id, char *arg); int get_rt_realms(__u32 *realms, char *arg); #endif /* __RTM_MAP_H__ */ --- NEW FILE: utils.h --- #ifndef __UTILS_H__ #define __UTILS_H__ 1 #include <asm/types.h> #include <resolv.h> #include "libnetlink.h" #include "ll_map.h" #include "rtm_map.h" extern int preferred_family; extern int show_stats; extern int show_details; extern int show_raw; extern int resolve_hosts; extern int oneline; extern char * _SL_; #ifndef IPPROTO_ESP #define IPPROTO_ESP 50 #endif #ifndef IPPROTO_AH #define IPPROTO_AH 51 #endif #define SPRINT_BSIZE 64 #define SPRINT_BUF(x) char x[SPRINT_BSIZE] extern void incomplete_command(void) __attribute__((noreturn)); #define NEXT_ARG() do { argv++; if (--argc <= 0) incomplete_command(); } while(0) typedef struct { __u8 family; __u8 bytelen; __s16 bitlen; __u32 data[4]; } inet_prefix; #define DN_MAXADDL 20 #ifndef AF_DECnet #define AF_DECnet 12 #endif struct dn_naddr { unsigned short a_len; unsigned char a_addr[DN_MAXADDL]; }; #define IPX_NODE_LEN 6 struct ipx_addr { u_int32_t ipx_net; u_int8_t ipx_node[IPX_NODE_LEN]; }; extern __u32 get_addr32(char *name); extern int get_addr_1(inet_prefix *dst, char *arg, int family); extern int get_prefix_1(inet_prefix *dst, char *arg, int family); extern int get_addr(inet_prefix *dst, char *arg, int family); extern int get_prefix(inet_prefix *dst, char *arg, int family); extern int get_integer(int *val, char *arg, int base); extern int get_unsigned(unsigned *val, char *arg, int base); #define get_byte get_u8 #define get_ushort get_u16 #define get_short get_s16 extern int get_u32(__u32 *val, char *arg, int base); extern int get_u16(__u16 *val, char *arg, int base); extern int get_s16(__s16 *val, char *arg, int base); extern int get_u8(__u8 *val, char *arg, int base); extern int get_s8(__s8 *val, char *arg, int base); extern const char *format_host(int af, int len, void *addr, char *buf, int buflen); extern const char *rt_addr_n2a(int af, int len, void *addr, char *buf, int buflen); void invarg(char *, char *) __attribute__((noreturn)); void duparg(char *, char *) __attribute__((noreturn)); void duparg2(char *, char *) __attribute__((noreturn)); int matches(char *arg, char *pattern); extern int inet_addr_match(inet_prefix *a, inet_prefix *b, int bits); const char *dnet_ntop(int af, const void *addr, char *str, size_t len); int dnet_pton(int af, const char *src, void *addr); const char *ipx_ntop(int af, const void *addr, char *str, size_t len); int ipx_pton(int af, const char *src, void *addr); extern int __iproute2_hz_internal; extern int __get_hz(void); static __inline__ int get_hz(void) { if (__iproute2_hz_internal == 0) __iproute2_hz_internal = __get_hz(); return __iproute2_hz_internal; } #endif /* __UTILS_H__ */ |
From: Patrick C. <pa...@us...> - 2003-05-04 11:53:35
|
Update of /cvsroot/linux-decnet/dnprogs/dnroute In directory sc8-pr-cvs1:/tmp/cvs-serv3636 Modified Files: Makefile get_neigh.c routing_msg.c Log Message: Fix routing messages incorporate as much of iproute2 as we need into the tree. Index: Makefile =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnroute/Makefile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** Makefile 4 May 2003 10:46:44 -0000 1.3 --- Makefile 4 May 2003 11:53:30 -0000 1.4 *************** *** 1,15 **** include ../Makefile.common - IPROUTE2=/usr/local/src/iproute2 - DNROUTE=dnroute ! CC=gcc -g -Wall -Wstrict-prototypes -I$(IPROUTE2)/include all: $(DNROUTE) ! $(DNROUTE): get_neigh.c send_route.c routing_msg.c csum.c ! $(CC) $(CFLAGS) -o $@ $^ -L$(IPROUTE2)/lib -lnetlink -lutil -ldnet clean: ! rm -f $(DNROUTE) *~ *.o --- 1,16 ---- include ../Makefile.common DNROUTE=dnroute ! CC=gcc -O2 -Wall -Wstrict-prototypes -Inetlink/include all: $(DNROUTE) ! $(DNROUTE): get_neigh.c send_route.c routing_msg.c csum.c netlink/libnetlink.a ! $(CC) $(CFLAGS) -o $@ $^ -Lnetlink -ldnet -lnetlink ! ! netlink/libnetlink.a: ! $(MAKE) -C netlink clean: ! rm -f $(DNROUTE) *~ *.o netlink/*.o netlink/*.a Index: get_neigh.c =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnroute/get_neigh.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** get_neigh.c 4 May 2003 10:46:45 -0000 1.1 --- get_neigh.c 4 May 2003 11:53:31 -0000 1.2 *************** *** 42,46 **** #include "utils.h" #include "libnetlink.h" - #include "dnrtlink.h" #include "csum.h" --- 42,45 ---- *************** *** 54,58 **** extern char *if_index_to_name(int ifindex); extern int routing_multicast_timer; ! extern int send_route_msg(void); int verbose; --- 53,57 ---- extern char *if_index_to_name(int ifindex); extern int routing_multicast_timer; ! extern int send_route_msg(char *); int verbose; *************** *** 153,159 **** } - if (send_routing) - send_route_msg(); - return 0; } --- 152,155 ---- *************** *** 181,184 **** --- 177,183 ---- } + if (send_routing) + send_route_msg(node_table); + /* Schedule us again */ resched: *************** *** 223,226 **** --- 222,226 ---- case 'r': send_routing++; + break; case 'V': Index: routing_msg.c =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnroute/routing_msg.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** routing_msg.c 4 May 2003 10:46:45 -0000 1.1 --- routing_msg.c 4 May 2003 11:53:31 -0000 1.2 *************** *** 29,33 **** #include "libnetlink.h" - #include "dnrtlink.h" #include "utils.h" #include "csum.h" --- 29,32 ---- |
From: Patrick C. <pa...@us...> - 2003-05-04 11:29:44
|
Update of /cvsroot/linux-decnet/dnprogs/dnroute/netlink/include In directory sc8-pr-cvs1:/tmp/cvs-serv27616/include Log Message: Directory /cvsroot/linux-decnet/dnprogs/dnroute/netlink/include added to the repository |
From: Patrick C. <pa...@us...> - 2003-05-04 11:29:07
|
Update of /cvsroot/linux-decnet/dnprogs/dnroute/netlink In directory sc8-pr-cvs1:/tmp/cvs-serv27291/netlink Log Message: Directory /cvsroot/linux-decnet/dnprogs/dnroute/netlink added to the repository |
From: Patrick C. <pa...@us...> - 2003-05-04 10:46:49
|
Update of /cvsroot/linux-decnet/dnprogs/dnroute In directory sc8-pr-cvs1:/tmp/cvs-serv8405 Modified Files: Makefile dnrtlink.c send_route.c Added Files: get_neigh.c routing_msg.c Removed Files: dnroute.c Log Message: largely working dnroute daemon. work to do: remove dependancy on external iproute2 sources. remove dead routes. --- NEW FILE: get_neigh.c --- /* * get_neigh.c DECnet routing daemon (eventually...) * * 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. * * Authors: Patrick Caulfield <pa...@Ch...> * based on rtmon.c by Alexey Kuznetsov, <ku...@ms...> * */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <syslog.h> #include <fcntl.h> #include <search.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/time.h> #include <netinet/in.h> #include <string.h> #include <linux/netfilter_decnet.h> #include <netdnet/dnetdb.h> #include <features.h> /* for the glibc version number */ #if (__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || __GLIBC__ >= 3 #include <netpacket/packet.h> #include <net/ethernet.h> /* the L2 protocols */ #include <net/if.h> #include <net/if_arp.h> #else #include <asm/types.h> #include <linux/if.h> #include <linux/if_arp.h> #include <linux/if_packet.h> #include <linux/if_ether.h> /* The L2 protocols */ #endif #include "utils.h" #include "libnetlink.h" #include "dnrtlink.h" #include "csum.h" /* A list of all possible nodes in our area. the byte is set to 0: unavailable 1: available 2: us */ static unsigned char node_table[1024]; extern char *if_index_to_name(int ifindex); extern int routing_multicast_timer; extern int send_route_msg(void); int verbose; static int send_routing; static struct rtnl_handle talk_rth; static struct rtnl_handle listen_rth; static int first_time = 1; /* Add or replace route to a node */ static int add_route(unsigned short node, int interface) { struct { struct nlmsghdr n; struct rtmsg r; char buf[1024]; } req; memset(&req, 0, sizeof(req)); req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); req.n.nlmsg_flags = NLM_F_REQUEST|NLM_F_CREATE|NLM_F_REPLACE; req.n.nlmsg_type = RTM_NEWROUTE; req.r.rtm_family = AF_DECnet; req.r.rtm_table = RT_TABLE_MAIN; req.r.rtm_protocol = RTPROT_BOOT; req.r.rtm_scope = RT_SCOPE_LINK; req.r.rtm_type = RTN_UNICAST; req.r.rtm_dst_len = 16; ll_init_map(&talk_rth); addattr_l(&req.n, sizeof(req), RTA_DST, &node, 2); addattr32(&req.n, sizeof(req), RTA_OIF, interface); return rtnl_talk(&talk_rth, &req.n, 0, 0, NULL, NULL, NULL); } /* Called for each neighbour node in the list */ static int got_neigh(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) { struct ndmsg *r = NLMSG_DATA(n); struct rtattr * tb[NDA_MAX+1]; memset(tb, 0, sizeof(tb)); parse_rtattr(tb, NDA_MAX, NDA_RTA(r), n->nlmsg_len - NLMSG_LENGTH(sizeof(*r))); if (tb[NDA_DST]) { unsigned char *addr = RTA_DATA(tb[NDA_DST]); unsigned short faddr = addr[0] | (addr[1]<<8); char nodekey[3]; int interface = r->ndm_ifindex; ENTRY *e,s; int node = faddr & 0x3ff; if (verbose) printf("got node %d.%d on %s\n", faddr>>10, node, if_index_to_name(interface)); /* Look it up in the hash table */ nodekey[0] = addr[0]; nodekey[1] = addr[1]; nodekey[2] = '\0'; s.key = nodekey; e = hsearch(s, FIND); /* If it's not there or the interface has changed then update the routing table */ if (!e || (int)e->data != interface) { ENTRY e1; if (!e) { e = &e1; e->key = nodekey; e->data = (void *)interface; } /* Update hash table */ hsearch(*e, ENTER); /* update the node table */ if (interface == 0) node_table[node] = 2; /* Us */ else node_table[node] = 1; /* TODO remove old nodes */ /* Set route using netlink */ if (add_route(faddr, interface) < 0) printf("Add route failed\n"); } } if (send_routing) send_route_msg(); return 0; } static void get_neighbours(int dummy) { if (first_time) { if (rtnl_open(&talk_rth, 0) < 0) goto resched; if (rtnl_open(&listen_rth, 0) < 0) goto resched; first_time = 0; } /* Get the list of adjacent nodes */ if (rtnl_wilddump_request(&listen_rth, AF_DECnet, RTM_GETNEIGH) < 0) { perror("Cannot send dump request"); goto resched; } if (rtnl_dump_filter(&listen_rth, got_neigh, stdout, NULL, NULL) < 0) { fprintf(stderr, "Dump terminated\n"); goto resched; } /* Schedule us again */ resched: alarm(routing_multicast_timer); } static void usage(char *cmd, FILE *f) { fprintf(f, "\nusage: %s [OPTIONS]\n\n", cmd); fprintf(f, " -h Print this help message\n"); fprintf(f, " -d Don't fork into background\n"); fprintf(f, " -r Send DECnet routing messages\n"); fprintf(f, " -V Show program version\n"); fprintf(f, "\n"); } int main(int argc, char **argv) { int opt; int no_daemon=0; while ((opt=getopt(argc,argv,"?Vvhrd")) != EOF) { switch(opt) { case 'h': usage(argv[0], stdout); exit(0); case '?': // Called if getopt doesn't recognise the option usage(argv[0], stderr); exit(0); case 'v': verbose++; break; case 'd': no_daemon++; break; case 'r': send_routing++; case 'V': printf("\ndnroute from dnprogs version %s\n\n", VERSION); exit(1); break; } } if (!no_daemon) { pid_t pid; switch ( pid=fork() ) { case -1: perror("dnroute: can't fork"); exit(2); case 0: // child break; default: // Parent. if (verbose > 1) printf("server: forked process %d\n", pid); exit(0); } // Detach ourself from the calling environment int devnull = open("/dev/null", O_RDWR); close(0); close(1); close(2); setsid(); dup2(devnull, 0); dup2(devnull, 1); dup2(devnull, 2); chdir("/"); } /* initialise the hash table */ hcreate(1024); signal(SIGALRM, get_neighbours); /* Start it off */ get_neighbours(0); while(1) pause(); exit(0); } --- NEW FILE: routing_msg.c --- /* * dnroute.c DECnet routing daemon (eventually...) * * 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. * * Authors: Patrick Caulfield <pa...@Ch...> * based on rtmon.c by Alexey Kuznetsov, <ku...@ms...> * */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <syslog.h> #include <signal.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/time.h> #include <net/if.h> #include <net/if_arp.h> #include <netinet/in.h> #include <string.h> #include <linux/netfilter_decnet.h> #include <netdnet/dnetdb.h> #include "libnetlink.h" #include "dnrtlink.h" #include "utils.h" #include "csum.h" int routing_multicast_timer = 15; extern void send_route_msg(int); char *if_index_to_name(int ifindex) { struct ifreq ifr; static char buf[64]; int sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); ifr.ifr_ifindex = ifindex; if (ioctl(sock, SIOCGIFNAME, &ifr) == 0) { strcpy(buf, ifr.ifr_name); } else { sprintf(buf, "if%d", ifindex); } close(sock); return buf; } static int dump_neigh_msg(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) { struct nf_dn_rtmsg *rtm; unsigned short *ptr2; unsigned char *ptr1; int len, i; unsigned int sum=1; rtm = (struct nf_dn_rtmsg *)NLMSG_DATA(n); ptr2 = (unsigned short *)NFDN_RTMSG(rtm); ptr1 = (unsigned char *)NFDN_RTMSG(rtm); len = n->nlmsg_len - sizeof(*n) - sizeof(*rtm); printf("PJC: got rtnetlink message, len = %d\n", len); #define DUMP_PACKET #ifdef DUMP_PACKET for (i=0; i<len/2; i++) { if (!(i&0xf)) fprintf(stderr, "\n"); fprintf(stderr, "%04x ", *(ptr2+i)); } fprintf(stderr, "\n"); #endif return 0; } /* Dump a routing message to stdout */ static int dump_rtg_msg(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) { struct nf_dn_rtmsg *rtm; unsigned short *ptr2; unsigned char *ptr1; int len, i; unsigned int sum=1; rtm = (struct nf_dn_rtmsg *)NLMSG_DATA(n); ptr2 = (unsigned short *)NFDN_RTMSG(rtm); ptr1 = (unsigned char *)NFDN_RTMSG(rtm); len = n->nlmsg_len - sizeof(*n) - sizeof(*rtm); #ifdef DUMP_PACKET for (i=0; i<len/2; i++) { if (!(i&0xf)) fprintf(stderr, "\n"); fprintf(stderr, "%04x ", *(ptr2+i)); } fprintf(stderr, "\n"); #endif /* Level 1 Routing Message */ if ( (ptr1[0] & 0xE)>>1 == 3) { struct dn_naddr add; char node[32]; int num; int num_ids; int start_id; int entry; i = 4; /* Start of segments */ add.a_len = 2; add.a_addr[0] = ptr1[1]; add.a_addr[1] = ptr1[2]; dnet_ntop(AF_DECnet, &add, node, sizeof(node)); printf("Level 1 routing message from %s on %s, len = %d\n", node, if_index_to_name(rtm->nfdn_ifindex), len); while (i < len-4) { num_ids = ptr1[i] | ptr1[i+1]<<8; i+=2; start_id = ptr1[i] | ptr1[i+1]<<8; i+=2; /* Start of entries */ for (num = 0; num<num_ids; num++) { entry = ptr1[i] | ptr1[i+1]<<8; if (entry != 0x7fff) { printf(" Node %d reachable. Hops %d, cost %d\n", num+start_id, (entry&0x7E00)>>9, entry&0x1FF); } i+=2; } } } /* Level 2 Routing Message */ if ( (ptr1[0] & 0xE)>>1 == 4) { struct dn_naddr add; char node[32]; int num; int num_ids; int start_id; int entry; i = 4; /* Start of segments */ add.a_len = 2; add.a_addr[0] = ptr1[1]; add.a_addr[1] = ptr1[2]; dnet_ntop(AF_DECnet, &add, node, sizeof(node)); printf("Level 2 routing message from %s on %s, len = %d\n", node, if_index_to_name(rtm->nfdn_ifindex), len); while (i < len-4) { num_ids = ptr1[i] | ptr1[i+1]<<8; i+=2; start_id = ptr1[i] | ptr1[i+1]<<8; i+=2; /* Start of entries */ for (num = 0; num<num_ids; num++) { entry = ptr1[i] | ptr1[i+1]<<8; if (entry != 0x7fff) { printf(" Area %d reachable. Hops %d, cost %d\n", num+start_id, (entry&0x7E00)>>9, entry&0x1FF); } i+=2; } } } /* Check the checksum */ sum = route_csum(ptr1, 4, i); printf("Calc sum=%x, got sum: %x\n", sum, *(unsigned short *)(ptr1+i)); return 0; } Index: Makefile =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnroute/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** Makefile 17 Apr 2002 16:06:23 -0000 1.2 --- Makefile 4 May 2003 10:46:44 -0000 1.3 *************** *** 1,11 **** IPROUTE2=/usr/local/src/iproute2 DNROUTE=dnroute ! CC=gcc -g -Wall -fstrict-prototypes -I$(IPROUTE2)/include all: $(DNROUTE) ! $(DNROUTE): dnroute.c dnrtlink.c send_route.c csum.c $(CC) $(CFLAGS) -o $@ $^ -L$(IPROUTE2)/lib -lnetlink -lutil -ldnet --- 1,13 ---- + include ../Makefile.common + IPROUTE2=/usr/local/src/iproute2 DNROUTE=dnroute ! CC=gcc -g -Wall -Wstrict-prototypes -I$(IPROUTE2)/include all: $(DNROUTE) ! $(DNROUTE): get_neigh.c send_route.c routing_msg.c csum.c $(CC) $(CFLAGS) -o $@ $^ -L$(IPROUTE2)/lib -lnetlink -lutil -ldnet Index: dnrtlink.c =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnroute/dnrtlink.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** dnrtlink.c 19 Dec 2000 16:02:51 -0000 1.1 --- dnrtlink.c 4 May 2003 10:46:44 -0000 1.2 *************** *** 32,36 **** memset(rth, 0, sizeof(rth)); ! rth->fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_DNRTMSG); if (rth->fd < 0) { perror("Cannot open netlink socket"); --- 32,36 ---- memset(rth, 0, sizeof(rth)); ! rth->fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (rth->fd < 0) { perror("Cannot open netlink socket"); Index: send_route.c =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnroute/send_route.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** send_route.c 17 Apr 2002 16:06:23 -0000 1.3 --- send_route.c 4 May 2003 10:46:45 -0000 1.4 *************** *** 28,33 **** #include <netpacket/packet.h> #include <net/ethernet.h> /* the L2 protocols */ ! #include <net/if.h> ! #include <net/if_arp.h> #else #include <asm/types.h> --- 28,33 ---- #include <netpacket/packet.h> #include <net/ethernet.h> /* the L2 protocols */ ! #include <net/if.h> ! #include <net/if_arp.h> #else #include <asm/types.h> *************** *** 46,59 **** extern int routing_multicast_timer; - /* A list of all possible nodes in our area. the byte is set to - 0: unavailable - 1: available - 2: us - */ - static unsigned char node_table[1024]; - - /* Send a packet to all ethernet interfaces */ ! int send_to_all(int dnet_socket, char *packet, int len, struct sockaddr_ll *sock_info) { struct ifreq ifr; --- 46,51 ---- extern int routing_multicast_timer; /* Send a packet to all ethernet interfaces */ ! static int send_to_all(int dnet_socket, char *packet, int len, struct sockaddr_ll *sock_info) { struct ifreq ifr; *************** *** 61,65 **** int sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); ! ifr.ifr_ifindex = iindex; --- 53,57 ---- int sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); ! ifr.ifr_ifindex = iindex; *************** *** 67,71 **** { /* Only send to ethernet interfaces */ ! ioctl(sock, SIOCGIFHWADDR, &ifr); if (ifr.ifr_hwaddr.sa_family == ARPHRD_ETHER) { --- 59,63 ---- { /* Only send to ethernet interfaces */ ! ioctl(sock, SIOCGIFHWADDR, &ifr); if (ifr.ifr_hwaddr.sa_family == ARPHRD_ETHER) { *************** *** 74,81 **** (struct sockaddr *)sock_info, sizeof(*sock_info)) < 0) perror("sendto"); ! } ifr.ifr_ifindex = ++iindex; } ! close(sock); return 0; --- 66,73 ---- (struct sockaddr *)sock_info, sizeof(*sock_info)) < 0) perror("sendto"); ! } ifr.ifr_ifindex = ++iindex; } ! close(sock); return 0; *************** *** 86,90 **** "start" should be a multiple of 32 for the header to be added correctly */ ! static int send_routing_message(int start, int end, int dnet_socket, struct dn_naddr *exec) { struct sockaddr_ll sock_info; --- 78,83 ---- "start" should be a multiple of 32 for the header to be added correctly */ ! static int send_routing_message(char *node_table, int start, int end, ! int dnet_socket, struct dn_naddr *exec) { struct sockaddr_ll sock_info; *************** *** 97,101 **** packet[i++] = 0x9a; packet[i++] = 0x05; ! packet[i++] = 0x07; /* Level 1 routing message */ packet[i++] = exec->a_addr[0]; /* Our node address */ --- 90,94 ---- packet[i++] = 0x9a; packet[i++] = 0x05; ! packet[i++] = 0x07; /* Level 1 routing message */ packet[i++] = exec->a_addr[0]; /* Our node address */ *************** *** 156,186 **** } ! ! /* Called for each neighbour node in the list */ ! static int got_neigh(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) ! { ! struct ndmsg *r = NLMSG_DATA(n); ! struct rtattr * tb[NDA_MAX+1]; ! ! memset(tb, 0, sizeof(tb)); ! parse_rtattr(tb, NDA_MAX, NDA_RTA(r), n->nlmsg_len - NLMSG_LENGTH(sizeof(*r))); ! ! if (tb[NDA_DST]) ! { ! unsigned char *addr = RTA_DATA(tb[NDA_DST]); ! unsigned short faddr = addr[0] | (addr[1]<<8); ! ! int node = faddr & 0x3ff; ! ! if (!strcmp(if_index_to_name(r->ndm_ifindex), "lo")) ! node_table[node] = 2;/* It's us! */ ! else ! node_table[node] = 1;/* Reachable */ ! } ! ! return 0; ! } ! ! void send_route_msg(int dummy) { int dnet_socket; --- 149,153 ---- } ! void send_route_msg(char *node_table) { int dnet_socket; *************** *** 188,221 **** struct dn_naddr *addr; ! /* Clear out the nodes table */ ! memset(node_table, 0, sizeof(node_table)); ! ! /* Get the list of adjacent nodes */ ! if (rtnl_open(&rth, 0) < 0) ! goto resched; ! ! if (rtnl_wilddump_request(&rth, AF_DECnet, RTM_GETNEIGH) < 0) { ! perror("Cannot send dump request"); ! goto resched; ! } ! ! if (rtnl_dump_filter(&rth, got_neigh, stdout, NULL, NULL) < 0) { ! fprintf(stderr, "Dump terminated\n"); ! goto resched; ! } ! ! /* Build an L1 routing message from the node table */ ! addr = getnodeadd(); dnet_socket = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_DNA_RT)); /* 576 is a multiple of 32 so the mask in send_routine_message() works */ ! send_routing_message(0, 575, dnet_socket, addr); ! send_routing_message(576, 1023, dnet_socket, addr); close(dnet_socket); - - /* Schedule us again */ - resched: - alarm(routing_multicast_timer); } --- 155,167 ---- struct dn_naddr *addr; ! /* Get out node address */ ! addr = getnodeadd(); dnet_socket = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_DNA_RT)); /* 576 is a multiple of 32 so the mask in send_routine_message() works */ ! send_routing_message(node_table, 0, 575, dnet_socket, addr); ! send_routing_message(node_table, 576, 1023, dnet_socket, addr); close(dnet_socket); } --- dnroute.c DELETED --- |
From: Patrick C. <pa...@us...> - 2003-04-25 19:24:17
|
Update of /cvsroot/linux-decnet/latd In directory sc8-pr-cvs1:/tmp/cvs-serv4697 Modified Files: interfaces-bpf.cc Log Message: Proper version of last patch. Index: interfaces-bpf.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/interfaces-bpf.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** interfaces-bpf.cc 25 Apr 2003 19:08:37 -0000 1.7 --- interfaces-bpf.cc 25 Apr 2003 19:24:13 -0000 1.8 *************** *** 382,386 **** /* write this packet: */ ! iov[0].iov_base = (char* )ðer_packet; iov[0].iov_len = sizeof(ether_packet); iov[1].iov_base = data; --- 382,386 ---- /* write this packet: */ ! iov[0].iov_base = (unsigned char* )ðer_packet; iov[0].iov_len = sizeof(ether_packet); iov[1].iov_base = data; *************** *** 395,398 **** --- 395,404 ---- + #define CONT_OR_RET() \ + if (_latd_bpf_buffer_offset < _latd_bpf_buffer_end) \ + continue;\ + else \ + return 0; + // Receive a packet from a given interface int BPFInterfaces::recv_packet(int sockfd, int &ifn, unsigned char macaddr[], unsigned char *data, int maxlen) *************** *** 405,409 **** for(;;) { ! debuglog(("PJC: buffer_offset=%d, buffer_end=%d\n", _latd_bpf_buffer_offset,_latd_bpf_buffer_end)); /* if the buffer is empty, fill it: */ if (_latd_bpf_buffer_offset --- 411,415 ---- for(;;) { ! debuglog(("buffer_offset=%d, buffer_end=%d\n", _latd_bpf_buffer_offset,_latd_bpf_buffer_end)); /* if the buffer is empty, fill it: */ if (_latd_bpf_buffer_offset *************** *** 431,435 **** debuglog(("bpf: flushed garbage BPF header bytes\n")); _latd_bpf_buffer_end = 0; ! return 0; } --- 437,441 ---- debuglog(("bpf: flushed garbage BPF header bytes\n")); _latd_bpf_buffer_end = 0; ! CONT_OR_RET(); } *************** *** 451,455 **** _latd_bpf_buffer_offset, _latd_bpf_buffer_end)); _latd_bpf_buffer_offset = _latd_bpf_buffer_offset_next; ! return 0; } --- 457,461 ---- _latd_bpf_buffer_offset, _latd_bpf_buffer_end)); _latd_bpf_buffer_offset = _latd_bpf_buffer_offset_next; ! CONT_OR_RET(); } *************** *** 463,468 **** ETHER_ADDR_LEN)) { /* silently ignore packets from us: */ _latd_bpf_buffer_offset = _latd_bpf_buffer_offset_next; ! continue; } debuglog(("bpf: packet from %02x:%02x:%02x:%02x:%02x:%02x\n", --- 469,478 ---- ETHER_ADDR_LEN)) { /* silently ignore packets from us: */ + if (the_bpf_header.bh_datalen < sizeof(struct ether_header)) + debuglog(("ignoring short packet of %d bytes\n", the_bpf_header.bh_datalen)); + else + debuglog(("ignoring packet from us\n")); _latd_bpf_buffer_offset = _latd_bpf_buffer_offset_next; ! CONT_OR_RET(); } debuglog(("bpf: packet from %02x:%02x:%02x:%02x:%02x:%02x\n", |
From: Patrick C. <pa...@us...> - 2003-04-25 19:08:41
|
Update of /cvsroot/linux-decnet/latd In directory sc8-pr-cvs1:/tmp/cvs-serv29256 Modified Files: interfaces-bpf.cc Log Message: Cope better when more than one packet arrives in the BPF buffer. Fortunately this is almost always one from us that we can ignore. This area may need some serious revisiting in future. Index: interfaces-bpf.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/interfaces-bpf.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** interfaces-bpf.cc 14 Mar 2003 19:06:37 -0000 1.6 --- interfaces-bpf.cc 25 Apr 2003 19:08:37 -0000 1.7 *************** *** 464,468 **** /* silently ignore packets from us: */ _latd_bpf_buffer_offset = _latd_bpf_buffer_offset_next; ! return 0; } debuglog(("bpf: packet from %02x:%02x:%02x:%02x:%02x:%02x\n", --- 464,468 ---- /* silently ignore packets from us: */ _latd_bpf_buffer_offset = _latd_bpf_buffer_offset_next; ! continue; } debuglog(("bpf: packet from %02x:%02x:%02x:%02x:%02x:%02x\n", |
From: Patrick C. <pa...@us...> - 2003-04-25 07:19:29
|
Update of /cvsroot/linux-decnet/dnprogs/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv16230 Modified Files: check_kernel.sh Log Message: Don't issue that stupid "no patched kernel in /usr/src" message any more. If we cant find a kernel assume it's 2.4 or higher. Index: check_kernel.sh =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/scripts/check_kernel.sh,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** check_kernel.sh 13 Sep 2002 12:00:55 -0000 1.3 --- check_kernel.sh 25 Apr 2003 07:19:22 -0000 1.4 *************** *** 44,63 **** # Use our fallback include file # cp include/kernel/netdnet/dn.h include/netdnet - echo '*********************************************************************' - echo I can\'t find a patched kernel in /usr/src. - echo - echo If you haven\'t patched your kernel yet then I recommend you do - echo so before compiling these programs because they certainly won\'t - echo work without DECnet support in the kernel and it is important - echo that the programs know which version of the kernel patch you - echo are using. - echo - echo You can still compile the programs without the kernel available by - echo typing the command \'make please\' but be aware that some of the - echo programs may not work correctly or at all. If you do this so make - echo sure you know what you are doing. - echo - return 1 fi return 0 --- 44,49 ---- # Use our fallback include file # + echo Assuming 2.4+ kernel cp include/kernel/netdnet/dn.h include/netdnet fi return 0 |
From: Patrick C. <pa...@us...> - 2003-04-24 09:18:16
|
Update of /cvsroot/linux-decnet/latd In directory sc8-pr-cvs1:/tmp/cvs-serv11747 Modified Files: connection.cc Log Message: missing brackets cause funny things to happen if packet 255 gets lost. Index: connection.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/connection.cc,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -r1.58 -r1.59 *** connection.cc 14 Apr 2003 11:06:47 -0000 1.58 --- connection.cc 24 Apr 2003 09:18:11 -0000 1.59 *************** *** 171,178 **** // If the last DATA message wasn't seen either then resend that too if (last_message.get_seq() > msg->header.ack_number || ! last_message.get_seq() == 0 && msg->header.ack_number == 0xff) { ! debuglog(("Also sending mast DATA message (%d)\n", last_message.get_seq())); last_message.send(interface, last_recv_seq, macaddr); } --- 171,178 ---- // If the last DATA message wasn't seen either then resend that too if (last_message.get_seq() > msg->header.ack_number || ! (last_message.get_seq() == 0 && msg->header.ack_number == 0xff)) { ! debuglog(("Also sending last DATA message (%d)\n", last_message.get_seq())); last_message.send(interface, last_recv_seq, macaddr); } *************** *** 189,193 **** // If the last DATA message wasn't seen either then resend that too if (last_message.get_seq() > msg->header.ack_number || ! last_message.get_seq() == 0 && msg->header.ack_number == 0xff) { debuglog(("Also sending last DATA message (%d)\n", last_message.get_seq())); --- 189,193 ---- // If the last DATA message wasn't seen either then resend that too if (last_message.get_seq() > msg->header.ack_number || ! (last_message.get_seq() == 0 && msg->header.ack_number == 0xff)) { debuglog(("Also sending last DATA message (%d)\n", last_message.get_seq())); |
From: Patrick C. <pa...@us...> - 2003-04-22 18:34:41
|
Update of /cvsroot/linux-decnet/latd In directory sc8-pr-cvs1:/tmp/cvs-serv5721 Modified Files: mkrpm.sh Log Message: fix sysconfdir Index: mkrpm.sh =================================================================== RCS file: /cvsroot/linux-decnet/latd/mkrpm.sh,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** mkrpm.sh 17 Mar 2003 13:19:06 -0000 1.2 --- mkrpm.sh 22 Apr 2003 18:34:36 -0000 1.3 *************** *** 8,12 **** echo "`rpm --showrc|grep \^macrofiles`:`pwd`/.rpmmacros" >.rpmrc rm -rf rpmbuild BUILD RPMS config.cache ! ./configure --prefix=/usr --sysconfdir=/ --- 8,12 ---- echo "`rpm --showrc|grep \^macrofiles`:`pwd`/.rpmmacros" >.rpmrc rm -rf rpmbuild BUILD RPMS config.cache ! ./configure --prefix=/usr --sysconfdir=/etc |
From: Patrick C. <pa...@us...> - 2003-04-21 16:20:38
|
Update of /cvsroot/linux-decnet/dnprogs/dnlogin In directory sc8-pr-cvs1:/tmp/cvs-serv31736 Modified Files: cterm.c dnlogin.c dnlogin.h tty.c Log Message: Terminator handling Index: cterm.c =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnlogin/cterm.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** cterm.c 21 Apr 2003 14:17:32 -0000 1.9 --- cterm.c 21 Apr 2003 16:20:34 -0000 1.10 *************** *** 1,4 **** /****************************************************************************** ! (c) 2002 P.J. Caulfield pa...@de... Portions based on code (c) 2000 Eduardo M Serrat --- 1,4 ---- /****************************************************************************** ! (c) 2002-2003 P.J. Caulfield pa...@de... Portions based on code (c) 2000 Eduardo M Serrat *************** *** 152,178 **** unsigned char term_len; int ptr = 0; ! flags = buf[1] | buf[2] << 8 | buf[3] << 16; ptr = 4; ! maxlength = buf[ptr] | buf[ptr+1]<<8; ptr += 2; ! eodata = buf[ptr] | buf[ptr+1]<<8; ptr += 2; ! timeout = buf[ptr] | buf[ptr+1]<<8; ptr += 2; ! eoprompt = buf[ptr] | buf[ptr+1]<<8; ptr += 2; ! sodisplay = buf[ptr] | buf[ptr+1]<<8; ptr += 2; ! lowwater = buf[ptr] | buf[ptr+1]<<8; ptr += 2; term_len = buf[ptr++]; // TODO more flags ! if (debug & 2) fprintf(stderr, "CTERM: flags = %x\n",flags); if (flags & 4) tty_clear_typeahead(); if (flags & 0x800) tty_set_noecho(); ! if (debug & 2) fprintf(stderr, "term_len = %d\n", term_len); ! tty_set_terminators(buf+ptr, term_len); ! tty_start_read(buf+ptr+term_len, len-term_len-ptr-1, eoprompt); tty_set_timeout(timeout); tty_set_maxlen(maxlength); return len; --- 152,186 ---- unsigned char term_len; int ptr = 0; + unsigned char ZZ; ! flags = buf[1] | (buf[2] << 8) | (buf[3] << 16); ptr = 4; ! maxlength = buf[ptr] | (buf[ptr+1]<<8); ptr += 2; ! eodata = buf[ptr] | (buf[ptr+1]<<8); ptr += 2; ! timeout = buf[ptr] | (buf[ptr+1]<<8); ptr += 2; ! eoprompt = buf[ptr] | (buf[ptr+1]<<8); ptr += 2; ! sodisplay = buf[ptr] | (buf[ptr+1]<<8); ptr += 2; ! lowwater = buf[ptr] | (buf[ptr+1]<<8); ptr += 2; term_len = buf[ptr++]; + ZZ = (flags>>14)&3; + // TODO more flags ! if (debug & 2) fprintf(stderr, "CTERM: flags = %x (ZZ=%d)\n",flags, ZZ); ! if (debug & 2) fprintf(stderr, "CTERM: len=%d, term_len=%d, ptr=%d\n", ! len, term_len, ptr); ! if (debug & 2) fprintf(stderr, "CTERM: timeout = %d\n", timeout); ! if (flags & 4) tty_clear_typeahead(); if (flags & 0x800) tty_set_noecho(); ! if (ZZ==1) tty_set_terminators(buf+ptr, term_len); ! if (ZZ==2) tty_set_default_terminators(); ! tty_start_read(buf+ptr+term_len, len-term_len-ptr, eoprompt); tty_set_timeout(timeout); tty_set_maxlen(maxlength); + tty_echo_terminator((flags>>12)&1); return len; Index: dnlogin.c =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnlogin/dnlogin.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** dnlogin.c 22 Jul 2002 16:08:55 -0000 1.7 --- dnlogin.c 21 Apr 2003 16:20:34 -0000 1.8 *************** *** 38,41 **** --- 38,42 ---- int debug = 0; + int char_timeout = 0; static int mainloop(void) *************** *** 44,47 **** --- 45,49 ---- { char inbuf[1024]; + struct timeval tv; fd_set in_set; Index: dnlogin.h =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnlogin/dnlogin.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** dnlogin.h 21 Apr 2003 14:17:32 -0000 1.9 --- dnlogin.h 21 Apr 2003 16:20:34 -0000 1.10 *************** *** 31,34 **** --- 31,35 ---- extern int tty_write(unsigned char *buf, int len); extern void tty_set_terminators(unsigned char *buf, int len); + void tty_set_default_terminators(void); extern void tty_start_read(char *prompt, int len, int promptlen); extern void tty_set_timeout(unsigned short to); *************** *** 39,42 **** --- 40,44 ---- extern void tty_clear_typeahead(void); extern void tty_set_noecho(void); + extern void tty_echo_terminator(int a); extern int (*send_input)(unsigned char *buf, int len, int flags); Index: tty.c =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnlogin/tty.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** tty.c 21 Apr 2003 14:17:32 -0000 1.8 --- tty.c 21 Apr 2003 16:20:34 -0000 1.9 *************** *** 1,4 **** /****************************************************************************** ! (c) 2002 P.J. Caulfield pa...@de... This program is free software; you can redistribute it and/or modify --- 1,4 ---- /****************************************************************************** ! (c) 2002-2003 P.J. Caulfield pa...@de... This program is free software; you can redistribute it and/or modify *************** *** 53,56 **** --- 53,60 ---- static int reading = 0; static int insert_mode = 0; + static int echo_terminator = 0; + + /* in dnlogin.c */ + extern int char_timeout; /* Output processors */ *************** *** 58,61 **** --- 62,77 ---- int (*send_oob)(char oobchar, int discard); + static void send_input_buffer(int flags) + { + char buf[1024]; + + memcpy(buf, input_buf, input_len); + + send_input(buf, input_len, flags); + input_len = input_pos = 0; + reading = 0; + echo = 1; + } + /* Raw write to terminal */ int tty_write(unsigned char *buf, int len) *************** *** 78,84 **** --- 94,123 ---- } + void tty_echo_terminator(int a) + { + if (debug & 4) + fprintf(stderr, "TTY: echo terminators = %d\n", a); + + echo_terminator = a; + } + + void tty_set_default_terminators() + { + if (debug & 4) + fprintf(stderr, "TTY: set default terminators\n"); + + /* All control chars except ^R ^U ^W, BS & HT */ + /* ie 18, 21, 23, 8, 9 */ + memset(terminators, 0, sizeof(terminators)); + terminators[0] = 0x7F; + terminators[1] = 0xFE; + terminators[2] = 0xAD; + terminators[3] = 0xFF; + } void tty_set_terminators(unsigned char *buf, int len) { + if (debug & 4) + fprintf(stderr, "TTY: set terminators... %d bytes\n", len); memset(terminators, 0, sizeof(terminators)); memcpy(terminators, buf, len); *************** *** 88,92 **** { if (debug & 4) ! fprintf(stderr, "TTY start_read promptlen = %d, maxlen=%d\n", promptlen, len); if (promptlen) write(termfd, prompt, promptlen); --- 127,131 ---- { if (debug & 4) ! fprintf(stderr, "TTY: start_read promptlen = %d, maxlen=%d\n", promptlen, len); if (promptlen) write(termfd, prompt, promptlen); *************** *** 103,113 **** max_read_len = len; ! /* Now add in any typeahead ! TODO: Are there flags to disable this? */ if (rahead_len) { int copylen = rahead_len; ! fprintf(stderr, "PJC: readahead = %d bytes\n", rahead_len); /* Don't overflow the input buffer */ if (input_len + copylen > sizeof(input_buf)) --- 142,153 ---- max_read_len = len; ! /* Now add in any typeahead */ if (rahead_len) { int copylen = rahead_len; ! if (debug & 4) ! fprintf(stderr, "TTY: readahead = %d bytes\n", rahead_len); ! /* Don't overflow the input buffer */ if (input_len + copylen > sizeof(input_buf)) *************** *** 123,127 **** void tty_set_timeout(unsigned short to) { ! // TODO: } --- 163,167 ---- void tty_set_timeout(unsigned short to) { ! char_timeout = to; } *************** *** 197,211 **** } - static void send_input_buffer(int flags) - { - char buf[1024]; - - memcpy(buf, input_buf, input_len); - - send_input(buf, input_len, flags); - input_len = input_pos = 0; - reading = 0; - echo = 1; - } void tty_send_unread() --- 237,240 ---- *************** *** 227,241 **** } /* Terminators */ ! // TODO: flag for echoing terminators ! if (is_terminator(buf[i])) { ! send_input(&buf[i], 1, 1); /* last "1" is "terminator" */ reading = 0; return 0; } ! ! /* Check for OOB - these discard input*/ if (buf[i] == CTRL_C || buf[i] == CTRL_Y) { --- 256,285 ---- } + /* Swap LF for CR */ + //PJC: is this right?? + if (buf[i] == '\n') + buf[i] = '\r'; + + /* Is it ESCAPE ? */ + if (buf[i] == ESC && esc_len == 0) + { + esc_buf[esc_len++] = buf[i]; + continue; + } + /* Terminators */ ! if (!esc_len && is_terminator(buf[i])) { ! if (echo_terminator) ! { ! write(termfd, &buf[i], 1); ! } ! input_buf[input_len++] = buf[i]; ! send_input_buffer(1); reading = 0; return 0; } ! /* Check for OOB - these discard input */ if (buf[i] == CTRL_C || buf[i] == CTRL_Y) { *************** *** 248,264 **** { send_oob(buf[i], 0); - continue; - } - - /* Swap LF for CR */ - //PJC: is this right?? - if (buf[i] == '\n') - buf[i] = '\r'; - - - /* Is it ESCAPE ? */ - if (buf[i] == ESC && esc_len == 0) - { - esc_buf[esc_len++] = buf[i]; continue; } --- 292,295 ---- |
From: Patrick C. <pa...@us...> - 2003-04-21 14:34:54
|
Update of /cvsroot/linux-decnet/dnprogs/dnlogin In directory sc8-pr-cvs1:/tmp/cvs-serv17987 Modified Files: cterm.c dnlogin.h found.c tty.c Log Message: Make buffer unsigned, fixes a multitude of oddities! clear readahead buffer length after use. Index: cterm.c =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnlogin/cterm.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** cterm.c 22 Jul 2002 16:08:54 -0000 1.8 --- cterm.c 21 Apr 2003 14:17:32 -0000 1.9 *************** *** 126,130 **** /* Process incoming CTERM messages */ ! static int cterm_process_initiate(char *buf, int len) { unsigned char initsq[] = --- 126,130 ---- /* Process incoming CTERM messages */ ! static int cterm_process_initiate(unsigned char *buf, int len) { unsigned char initsq[] = *************** *** 141,145 **** } ! static int cterm_process_start_read(char *buf, int len) { unsigned int flags; --- 141,145 ---- } ! static int cterm_process_start_read(unsigned char *buf, int len) { unsigned int flags; *************** *** 179,189 **** } ! static int cterm_process_read_data(char *buf, int len) {return len;} ! static int cterm_process_oob(char *buf, int len) {return len;} ! static int cterm_process_unread(char *buf, int len) { tty_send_unread(); --- 179,189 ---- } ! static int cterm_process_read_data(unsigned char *buf, int len) {return len;} ! static int cterm_process_oob(unsigned char *buf, int len) {return len;} ! static int cterm_process_unread(unsigned char *buf, int len) { tty_send_unread(); *************** *** 191,198 **** } ! static int cterm_process_clear_input(char *buf, int len) {return len;} ! static int cterm_process_write(char *buf, int len) { unsigned short flags = buf[1] | buf[2]<<8; --- 191,198 ---- } ! static int cterm_process_clear_input(unsigned char *buf, int len) {return len;} ! static int cterm_process_write(unsigned char *buf, int len) { unsigned short flags = buf[1] | buf[2]<<8; *************** *** 205,215 **** } ! static int cterm_process_write_complete(char *buf, int len) {return len;} ! static int cterm_process_discard_state(char *buf, int len) {return len;} ! static int cterm_process_read_characteristics(char *buf, int len) { int bufptr = 2;/* skip past flags */ --- 205,215 ---- } ! static int cterm_process_write_complete(unsigned char *buf, int len) {return len;} ! static int cterm_process_discard_state(unsigned char *buf, int len) {return len;} ! static int cterm_process_read_characteristics(unsigned char *buf, int len) { int bufptr = 2;/* skip past flags */ *************** *** 438,455 **** } ! static int cterm_process_characteristics(char *buf, int len) {return len;} ! static int cterm_process_check_input(char *buf, int len) {return len;} ! static int cterm_process_input_count(char *buf, int len) {return len;} ! static int cterm_process_input_state(char *buf, int len) {return len;} /* Process buffer from cterm host */ ! int cterm_process_network(char *buf, int len) { int offset = 0; --- 438,455 ---- } ! static int cterm_process_characteristics(unsigned char *buf, int len) {return len;} ! static int cterm_process_check_input(unsigned char *buf, int len) {return len;} ! static int cterm_process_input_count(unsigned char *buf, int len) {return len;} ! static int cterm_process_input_state(unsigned char *buf, int len) {return len;} /* Process buffer from cterm host */ ! int cterm_process_network(unsigned char *buf, int len) { int offset = 0; *************** *** 506,511 **** default: ! fprintf(stderr, "Unknown cterm message %d received\n", ! buf[offset]); return -1; } --- 506,511 ---- default: ! fprintf(stderr, "Unknown cterm message %d received, offset=%d\n", ! (unsigned char)buf[offset], offset); return -1; } *************** *** 528,532 **** } ! int cterm_send_input(char *buf, int len, int flags) { char newbuf[len+9]; --- 528,532 ---- } ! int cterm_send_input(unsigned char *buf, int len, int flags) { char newbuf[len+9]; Index: dnlogin.h =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnlogin/dnlogin.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** dnlogin.h 22 Jul 2002 16:08:55 -0000 1.8 --- dnlogin.h 21 Apr 2003 14:17:32 -0000 1.9 *************** *** 18,34 **** extern char *found_connerror(void); extern int found_getsockfd(void); ! extern int found_write(char *buf, int len); extern int found_read(void); ! extern int found_setup_link(char *node, int object, int (*processor)(char *, int)); ! extern int found_common_write(char *buf, int len); /* cterm/dterm routines */ ! extern int cterm_send_input(char *buf, int len, int flags); extern int cterm_send_oob(char, int); ! extern int cterm_process_network(char *buf, int len); /* TTY routines */ ! extern int tty_write(char *buf, int len); ! extern void tty_set_terminators(char *buf, int len); extern void tty_start_read(char *prompt, int len, int promptlen); extern void tty_set_timeout(unsigned short to); --- 18,34 ---- extern char *found_connerror(void); extern int found_getsockfd(void); ! extern int found_write(unsigned char *buf, int len); extern int found_read(void); ! extern int found_setup_link(char *node, int object, int (*processor)(unsigned char *, int)); ! extern int found_common_write(unsigned char *buf, int len); /* cterm/dterm routines */ ! extern int cterm_send_input(unsigned char *buf, int len, int flags); extern int cterm_send_oob(char, int); ! extern int cterm_process_network(unsigned char *buf, int len); /* TTY routines */ ! extern int tty_write(unsigned char *buf, int len); ! extern void tty_set_terminators(unsigned char *buf, int len); extern void tty_start_read(char *prompt, int len, int promptlen); extern void tty_set_timeout(unsigned short to); *************** *** 40,44 **** extern void tty_set_noecho(void); ! extern int (*send_input)(char *buf, int len, int flags); extern int (*send_oob)(char, int); --- 40,44 ---- extern void tty_set_noecho(void); ! extern int (*send_input)(unsigned char *buf, int len, int flags); extern int (*send_oob)(char, int); Index: found.c =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnlogin/found.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** found.c 25 Aug 2002 11:19:21 -0000 1.8 --- found.c 21 Apr 2003 14:17:32 -0000 1.9 *************** *** 91,95 **** static int sockfd = -1; ! static int (*terminal_processor)(char *, int); static int send_bindaccept(void) --- 91,95 ---- static int sockfd = -1; ! static int (*terminal_processor)(unsigned char *, int); static int send_bindaccept(void) *************** *** 121,125 **** /* Write "Common data" with a foundation header */ ! int found_common_write(char *buf, int len) { struct iovec vectors[2]; --- 121,125 ---- /* Write "Common data" with a foundation header */ ! int found_common_write(unsigned char *buf, int len) { struct iovec vectors[2]; *************** *** 163,167 **** { int len; ! char inbuf[1024]; int ptr = 0; --- 163,167 ---- { int len; ! unsigned char inbuf[1024]; int ptr = 0; *************** *** 239,243 **** /* Open the DECnet connection */ ! int found_setup_link(char *node, int object, int (*processor)(char *, int)) { struct nodeent *np; --- 239,243 ---- /* Open the DECnet connection */ ! int found_setup_link(char *node, int object, int (*processor)(unsigned char *, int)) { struct nodeent *np; Index: tty.c =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/dnlogin/tty.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** tty.c 25 Aug 2002 11:19:21 -0000 1.7 --- tty.c 21 Apr 2003 14:17:32 -0000 1.8 *************** *** 55,63 **** /* Output processors */ ! int (*send_input)(char *buf, int len, int flags); int (*send_oob)(char oobchar, int discard); /* Raw write to terminal */ ! int tty_write(char *buf, int len) { int i; --- 55,63 ---- /* Output processors */ ! int (*send_input)(unsigned char *buf, int len, int flags); int (*send_oob)(char oobchar, int discard); /* Raw write to terminal */ ! int tty_write(unsigned char *buf, int len) { int i; *************** *** 79,83 **** ! void tty_set_terminators(char *buf, int len) { memset(terminators, 0, sizeof(terminators)); --- 79,83 ---- ! void tty_set_terminators(unsigned char *buf, int len) { memset(terminators, 0, sizeof(terminators)); *************** *** 116,119 **** --- 116,120 ---- memcpy(input_buf+input_len, rahead_buf, copylen); input_len += copylen; + rahead_len = 0; } reading = 1; |
From: Patrick C. <pa...@us...> - 2003-04-20 10:07:09
|
Update of /cvsroot/linux-decnet/latd In directory sc8-pr-cvs1:/tmp/cvs-serv27662 Modified Files: configure.in Log Message: version 1.18 update Index: configure.in =================================================================== RCS file: /cvsroot/linux-decnet/latd/configure.in,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** configure.in 25 Mar 2003 10:35:39 -0000 1.5 --- configure.in 20 Apr 2003 10:07:05 -0000 1.6 *************** *** 3,7 **** dnl Checks that we are given a good source directory. AC_INIT(latcp.cc) ! AM_INIT_AUTOMAKE(latd, 1.17) dnl Checks for programs. --- 3,7 ---- dnl Checks that we are given a good source directory. AC_INIT(latcp.cc) ! AM_INIT_AUTOMAKE(latd, 1.18) dnl Checks for programs. |
From: Patrick C. <pa...@us...> - 2003-04-20 10:07:09
|
Update of /cvsroot/linux-decnet/latd/debian In directory sc8-pr-cvs1:/tmp/cvs-serv27662/debian Modified Files: changelog Log Message: version 1.18 update Index: changelog =================================================================== RCS file: /cvsroot/linux-decnet/latd/debian/changelog,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** changelog 15 Mar 2003 16:07:27 -0000 1.13 --- changelog 20 Apr 2003 10:07:05 -0000 1.14 *************** *** 1,2 **** --- 1,16 ---- + latd (1.18-1) unstable; urgency=low + + * Fix configure --enable-debug + * Fix configure --sysconfdir + * Don't send issue file if it exists but is empty. + * Add support for reverse-LAT services. you can now use LATSYM + to print to LAT printers on Linux (and probably many other things too!) + * Make sure node names are truncated at 16 characters + * Fix shell job control problems when connecting to some systems + * Send remote credit a little earlier in an attempt to avoid those + annoying pauses. + + -- Patrick Caulfield <pa...@de...> Sun, 20 Apr 2003 10:59:36 +0100 + latd (1.17-1) unstable; urgency=low |
From: Patrick C. <pa...@us...> - 2003-04-20 10:06:22
|
Update of /cvsroot/linux-decnet/latd/debian In directory sc8-pr-cvs1:/tmp/cvs-serv27552/debian Modified Files: rules Log Message: Correct position of latd.conf Index: rules =================================================================== RCS file: /cvsroot/linux-decnet/latd/debian/rules,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** rules 17 Mar 2003 13:18:52 -0000 1.7 --- rules 20 Apr 2003 10:06:19 -0000 1.8 *************** *** 7,11 **** build: $(checkdir) ! ./configure --prefix=/usr --sysconfdir=/ make touch build --- 7,11 ---- build: $(checkdir) ! ./configure --prefix=/usr --sysconfdir=/etc make touch build *************** *** 32,36 **** install -d debian/tmp/etc install -d debian/tmp/usr/share - install -m 0600 latd.conf debian/tmp/etc/latd.conf make install DESTDIR=`pwd`/debian/tmp mv debian/tmp/usr/man debian/tmp/usr/share --- 32,35 ---- |
From: Patrick C. <pa...@us...> - 2003-04-14 11:06:53
|
Update of /cvsroot/linux-decnet/latd In directory sc8-pr-cvs1:/tmp/cvs-serv3500 Modified Files: connection.cc Log Message: Send remote credit a little earler to avoid those annoying pauses. Index: connection.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/connection.cc,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -r1.57 -r1.58 *** connection.cc 7 Apr 2003 12:36:23 -0000 1.57 --- connection.cc 14 Apr 2003 11:06:47 -0000 1.58 *************** *** 225,229 **** if (session) session->add_credit(credits); } ! if (replyhere && session && session->get_remote_credit() < 1) { reply[0]->cmd |= 15; // Add credit --- 225,229 ---- if (session) session->add_credit(credits); } ! if (replyhere && session && session->get_remote_credit() <= 2) { reply[0]->cmd |= 15; // Add credit |
From: Patrick C. <pa...@us...> - 2003-04-13 12:11:43
|
Update of /cvsroot/linux-decnet/latd In directory sc8-pr-cvs1:/tmp/cvs-serv13333 Modified Files: serversession.cc Log Message: Make new pty the controlling TTY for the session Index: serversession.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/serversession.cc,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** serversession.cc 5 Apr 2003 10:01:21 -0000 1.17 --- serversession.cc 13 Apr 2003 12:11:40 -0000 1.18 *************** *** 15,18 **** --- 15,19 ---- #include <sys/types.h> #include <sys/time.h> + #include <sys/ioctl.h> #include <sys/resource.h> #include <stdio.h> *************** *** 163,166 **** --- 164,169 ---- int fd = slave_fd; + setsid(); + // Set terminal characteristics struct termios tio; *************** *** 168,171 **** --- 171,175 ---- tio.c_oflag |= ONLCR; tcsetattr(slave_fd, TCSANOW, &tio); + ioctl(fd, TIOCSCTTY, (char *)NULL); close(master_fd); *************** *** 176,181 **** close_all_fds(); - - setsid(); // Become the requested user. --- 180,183 ---- |
From: Patrick C. <pa...@us...> - 2003-04-13 10:54:38
|
Update of /cvsroot/linux-decnet/latd In directory sc8-pr-cvs1:/tmp/cvs-serv25256 Modified Files: server.cc Log Message: Make sure the node names don't get too long Index: server.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/server.cc,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -r1.71 -r1.72 *** server.cc 7 Apr 2003 12:36:25 -0000 1.71 --- server.cc 13 Apr 2003 10:54:34 -0000 1.72 *************** *** 98,104 **** uname(&uts); if (strchr(uts.nodename, '.')) - { *strchr(uts.nodename, '.') = '\0'; ! } strcpy((char *)local_name, uts.nodename); --- 98,111 ---- uname(&uts); if (strchr(uts.nodename, '.')) *strchr(uts.nodename, '.') = '\0'; ! ! // This gets rid of the name-Computer bit on Darwin ! if (strchr(uts.nodename, '-')) ! *strchr(uts.nodename, '-') = '\0'; ! ! // LAT node names must be <= 16 characters long ! if (strlen(uts.nodename) > 16) ! uts.nodename[16] = '\0'; ! strcpy((char *)local_name, uts.nodename); |
From: Patrick C. <pa...@us...> - 2003-04-07 12:36:34
|
Update of /cvsroot/linux-decnet/latd In directory sc8-pr-cvs1:/tmp/cvs-serv25829 Modified Files: connection.cc server.cc server.h Log Message: Fix a few comments. If create_reverse_session failed then tidy up. Add facility to track number of active services so we can do max_connections...later Index: connection.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/connection.cc,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -r1.56 -r1.57 *** connection.cc 5 Apr 2003 14:30:17 -0000 1.56 --- connection.cc 7 Apr 2003 12:36:23 -0000 1.57 *************** *** 375,379 **** uid_t uid; gid_t gid; ! LATServer::Instance()->get_service_info((char *)name, cmd, maxcon, uid, gid); strcpy((char *)servicename, (char *)name); --- 375,380 ---- uid_t uid; gid_t gid; ! int curcon; ! LATServer::Instance()->get_service_info((char *)name, cmd, maxcon, curcon, uid, gid); strcpy((char *)servicename, (char *)name); *************** *** 951,958 **** } ! debuglog(("---------------------------------------------------\n")); ! debuglog(("Deleting session %d, have %d session left\n", id, num_clients())); ! ! // TODO: Disconnect & Remove connection if no sessions active... if (num_clients() == 0) { --- 952,956 ---- } ! // Disconnect & Remove connection if no sessions active... if (num_clients() == 0) { *************** *** 1198,1202 **** // Create a server session for an incoming reverse-LAT connection - // PJC: may be able to reuse this code for above creation of ServerSessions int LATConnection::create_reverse_session(const char *service, const char *cmdbuf, --- 1196,1199 ---- *************** *** 1209,1216 **** uid_t uid; gid_t gid; debuglog(("Create reverse session for %s\n", service)); ! if (LATServer::Instance()->get_service_info((char *)service, cmd, maxcon, uid, gid) == -1) { debuglog(("Service not known\n")); --- 1206,1214 ---- uid_t uid; gid_t gid; + int curcon; debuglog(("Create reverse session for %s\n", service)); ! if (LATServer::Instance()->get_service_info((char *)service, cmd, maxcon, curcon, uid, gid) == -1) { debuglog(("Service not known\n")); Index: server.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/server.cc,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -r1.70 -r1.71 *** server.cc 5 Apr 2003 14:30:18 -0000 1.70 --- server.cc 7 Apr 2003 12:36:25 -0000 1.71 *************** *** 1109,1114 **** } ! // make a serversession and connect it. ! // make up a LAT_Start message and rem & local IDs. LAT_SessionStartCmd startcmd; memset(&startcmd, 0, sizeof(startcmd)); --- 1109,1113 ---- } ! // Make a reverse-session and connect it. LAT_SessionStartCmd startcmd; memset(&startcmd, 0, sizeof(startcmd)); *************** *** 1119,1123 **** interface, macaddr) == -1) { ! // TODO Destroy session & send error message. } } --- 1118,1125 ---- interface, macaddr) == -1) { ! // If we created this connection just for the new session ! // then get rid of it. ! if (connections[connid]->num_clients() == 0) ! delete_connection(connid); } } *************** *** 1280,1284 **** remove_fd(dsl.get_fd()); close(dsl.get_fd()); ! delete latcp_circuits[dsl.get_fd()]; /* PJC is this right ?? */ latcp_circuits.erase(dsl.get_fd()); break; --- 1282,1286 ---- remove_fd(dsl.get_fd()); close(dsl.get_fd()); ! delete latcp_circuits[dsl.get_fd()]; latcp_circuits.erase(dsl.get_fd()); break; *************** *** 1371,1375 **** // Return the command info for a service ! int LATServer::get_service_info(char *name, std::string &cmd, int &maxcon, uid_t &uid, gid_t &gid) { // Look for it. --- 1373,1377 ---- // Return the command info for a service ! int LATServer::get_service_info(char *name, std::string &cmd, int &maxcon, int &curcon, uid_t &uid, gid_t &gid) { // Look for it. *************** *** 1380,1383 **** --- 1382,1386 ---- cmd = sii->get_command(); maxcon = sii->get_max_connections(); + curcon = sii->get_cur_connections(); uid = sii->get_uid(); gid = sii->get_gid(); Index: server.h =================================================================== RCS file: /cvsroot/linux-decnet/latd/server.h,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** server.h 5 Apr 2003 10:01:23 -0000 1.41 --- server.h 7 Apr 2003 12:36:26 -0000 1.42 *************** *** 49,53 **** void send_connect_error(int reason, LAT_Header *msg, int interface, unsigned char *macaddr); bool is_local_service(char *); ! int get_service_info(char *name, std::string &cmd, int &maxcon, uid_t &uid, gid_t &gid); gid_t get_lat_group() { return lat_group; } LATConnection **get_connection(int id) { return &connections[id]; } --- 49,53 ---- void send_connect_error(int reason, LAT_Header *msg, int interface, unsigned char *macaddr); bool is_local_service(char *); ! int get_service_info(char *name, std::string &cmd, int &maxcon, int &curcon, uid_t &uid, gid_t &gid); gid_t get_lat_group() { return lat_group; } LATConnection **get_connection(int id) { return &connections[id]; } *************** *** 194,197 **** --- 194,198 ---- rating(r), max_connections(mc), + cur_connections(0), static_rating(s), cmd_uid(uid), *************** *** 205,208 **** --- 206,210 ---- const std::string &get_command() {return command;} int get_max_connections() {return max_connections;} + int get_cur_connections() {return cur_connections;} uid_t get_uid() {return cmd_uid;} gid_t get_gid() {return cmd_gid;} *************** *** 213,216 **** --- 215,220 ---- void set_ident(char *_ident) { id = std::string(_ident);} + void inc_connections() {cur_connections++;} + void dec_connections() {cur_connections--;} const bool operator==(serviceinfo &si) { return (si == name);} *************** *** 225,228 **** --- 229,233 ---- int rating; int max_connections; + int cur_connections; bool static_rating; uid_t cmd_uid; |
From: Patrick C. <pa...@us...> - 2003-04-05 14:30:23
|
Update of /cvsroot/linux-decnet/latd In directory sc8-pr-cvs1:/tmp/cvs-serv29018 Modified Files: connection.cc reversesession.cc server.cc Log Message: Reuse connections for reverse-LAT sessions * Only reuse conectiions (under any circumstance) if there are free session slots. * Still an odd bug where we don't seem to get a session disconnect from VMS. Index: connection.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/connection.cc,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -r1.55 -r1.56 *** connection.cc 5 Apr 2003 11:13:39 -0000 1.55 --- connection.cc 5 Apr 2003 14:30:17 -0000 1.56 *************** *** 951,964 **** } // TODO: Disconnect & Remove connection if no sessions active... if (num_clients() == 0) { ! LAT_Header msg; ! msg.local_connid = remote_connid; ! msg.remote_connid = num; ! msg.sequence_number = ++last_sent_seq; ! msg.ack_number = last_recv_ack; ! LATServer::Instance()->send_connect_error(3, &msg, interface, macaddr); ! LATServer::Instance()->delete_connection(num); } } --- 951,967 ---- } + debuglog(("---------------------------------------------------\n")); + debuglog(("Deleting session %d, have %d session left\n", id, num_clients())); + // TODO: Disconnect & Remove connection if no sessions active... if (num_clients() == 0) { ! LAT_Header msg; ! msg.local_connid = remote_connid; ! msg.remote_connid = num; ! msg.sequence_number = ++last_sent_seq; ! msg.ack_number = last_recv_ack; ! LATServer::Instance()->send_connect_error(3, &msg, interface, macaddr); ! LATServer::Instance()->delete_connection(num); } } *************** *** 1084,1098 **** add_string(buf, &ptr, (unsigned char *)LATServer::greeting); - // If we have a request ID then this is a connect for a - // queued connection (via a COMMAND message) so we need to include - // it as parameter 2 in the connect message - if (request_id) - { - buf[ptr++] = 2; // Parameter number - buf[ptr++] = 2; // Length of the short int - buf[ptr++] = request_id & 0xFF; - buf[ptr++] = request_id >> 8; - } - // Save the time we sent the connect so we // know if we got a response. --- 1087,1090 ---- *************** *** 1250,1254 **** // Start it connecting. ! rev_connect(); return 0; } --- 1242,1250 ---- // Start it connecting. ! if (!connected && !connecting) ! rev_connect(); ! ! if (connected) ! newsession->connect(); return 0; } Index: reversesession.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/reversesession.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** reversesession.cc 5 Apr 2003 11:13:39 -0000 1.2 --- reversesession.cc 5 Apr 2003 14:30:18 -0000 1.3 *************** *** 60,63 **** --- 60,65 ---- strcpy(remote_node, (char *)_remote_node); + + // Start local command return create_session(_remote_node); } Index: server.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/server.cc,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -r1.69 -r1.70 *** server.cc 5 Apr 2003 11:13:39 -0000 1.69 --- server.cc 5 Apr 2003 14:30:18 -0000 1.70 *************** *** 1095,1107 **** // Make a new connection ! // TODO: we can reuse connections here... ! int connid = get_next_connection_number(); ! connections[connid] = new LATConnection(connid, ! (char *)service, ! (char *)remport, ! (char *)portname, ! (char *)remnode, ! false, ! true); // make a serversession and connect it. --- 1095,1111 ---- // Make a new connection ! // We can reuse connections here... ! int connid = find_connection_by_node((char *)remnode); ! if (connid == -1) ! { ! connid = get_next_connection_number(); ! connections[connid] = new LATConnection(connid, ! (char *)service, ! (char *)remport, ! (char *)portname, ! (char *)remnode, ! false, ! true); ! } // make a serversession and connect it. *************** *** 1115,1119 **** interface, macaddr) == -1) { ! // TODO Destroy connection & send error message. } } --- 1119,1123 ---- interface, macaddr) == -1) { ! // TODO Destroy session & send error message. } } *************** *** 1816,1820 **** { if (connections[i] && ! connections[i]->node_is(node)) { debuglog(("Reusing connection for node %s\n", node)); --- 1820,1825 ---- { if (connections[i] && ! connections[i]->node_is(node) && ! connections[i]->num_clients() < MAX_CONNECTIONS-1) { debuglog(("Reusing connection for node %s\n", node)); |
From: Patrick C. <pa...@us...> - 2003-04-05 11:13:43
|
Update of /cvsroot/linux-decnet/latd In directory sc8-pr-cvs1:/tmp/cvs-serv29545 Modified Files: connection.cc reversesession.cc server.cc session.cc reversesession.h session.h TODO Log Message: The request ID goes in the session connect packet rather than the connection connect packet.. reverse-LAT services now work ! Still to do: - reuse-connections* - queued connections - limited connections. * This to finish before release. the others may wait. Index: connection.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/connection.cc,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -r1.54 -r1.55 *** connection.cc 5 Apr 2003 10:01:20 -0000 1.54 --- connection.cc 5 Apr 2003 11:13:39 -0000 1.55 *************** *** 729,746 **** add_string(buf, &ptr, LATServer::Instance()->get_local_node()); add_string(buf, &ptr, (unsigned char *)LATServer::greeting); - - if (request_id) - { - buf[ptr++] = 1; // Parameter number - buf[ptr++] = 2; // Length of the short int - buf[ptr++] = 2; - buf[ptr++] = 0; - - buf[ptr++] = 2; // Parameter number - buf[ptr++] = 2; // Length of the short int - buf[ptr++] = request_id & 0xFF; - buf[ptr++] = request_id >> 8; - } - send_message(buf, ptr, LATConnection::DATA); return; --- 729,732 ---- *************** *** 1098,1102 **** add_string(buf, &ptr, (unsigned char *)LATServer::greeting); ! // If we have a request ID then this is a connect for a // queued connection (via a COMMAND message) so we need to include // it as parameter 2 in the connect message --- 1084,1088 ---- add_string(buf, &ptr, (unsigned char *)LATServer::greeting); ! // If we have a request ID then this is a connect for a // queued connection (via a COMMAND message) so we need to include // it as parameter 2 in the connect message *************** *** 1161,1179 **** add_string(buf, &ptr, LATServer::Instance()->get_local_node()); - // Add in the request ID - buf[ptr++] = 1; // Parameter number - buf[ptr++] = 2; // Length of the short int - buf[ptr++] = 2; - buf[ptr++] = 0; - - buf[ptr++] = 2; // Parameter number - buf[ptr++] = 2; // Length of the short int - buf[ptr++] = request_id & 0xFF; - buf[ptr++] = request_id >> 8; - - // NOTES: params 4 & 5 have port name in - // param 6 is short int "1" - - // Save the time we sent the connect so we // know if we got a response. --- 1147,1150 ---- *************** *** 1247,1251 **** gid_t gid; ! debuglog(("Create server session for %s\n", service)); if (LATServer::Instance()->get_service_info((char *)service, cmd, maxcon, uid, gid) == -1) --- 1218,1222 ---- gid_t gid; ! debuglog(("Create reverse session for %s\n", service)); if (LATServer::Instance()->get_service_info((char *)service, cmd, maxcon, uid, gid) == -1) *************** *** 1276,1279 **** --- 1247,1251 ---- } sessions[newsessionnum] = newsession; + newsession->set_request_id(reqid); // Start it connecting. *************** *** 1338,1342 **** { int ptr = sizeof(LAT_SessionCmd)+3; - unsigned char temp[256]; ptr += buf[ptr]+1; // Skip over destination service --- 1310,1313 ---- *************** *** 1347,1350 **** --- 1318,1322 ---- queued_slave = false; + // Do parameters -- look for a 2 while (ptr < len) *************** *** 1360,1377 **** queued_slave = true; ptr +=2; ! // return true; } else { - printf("PJC: got param %d, len=%d\n", param_type, buf[ptr]); - printf("PJC: value: "); - for (int i=0; i< buf[ptr]; i++) - printf("%02x (%c) ", buf[ptr+i+1], buf[ptr+i+1]); - printf("\n"); ptr += buf[ptr]+1; // Skip over it - } } ! return queued_slave; } --- 1332,1343 ---- queued_slave = true; ptr +=2; ! return true; } else { ptr += buf[ptr]+1; // Skip over it } } ! return false; } Index: reversesession.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/reversesession.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** reversesession.cc 5 Apr 2003 10:01:21 -0000 1.1 --- reversesession.cc 5 Apr 2003 11:13:39 -0000 1.2 *************** *** 60,67 **** strcpy(remote_node, (char *)_remote_node); ! int status = create_session(_remote_node); ! if (status == 0) ! { ! // connect(); ! } } --- 60,63 ---- strcpy(remote_node, (char *)_remote_node); ! return create_session(_remote_node); } Index: server.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/server.cc,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -r1.68 -r1.69 *** server.cc 5 Apr 2003 10:01:21 -0000 1.68 --- server.cc 5 Apr 2003 11:13:39 -0000 1.69 *************** *** 1095,1099 **** // Make a new connection ! // TODO: can we reuse connections here ???? int connid = get_next_connection_number(); connections[connid] = new LATConnection(connid, --- 1095,1099 ---- // Make a new connection ! // TODO: we can reuse connections here... int connid = get_next_connection_number(); connections[connid] = new LATConnection(connid, *************** *** 1112,1116 **** if (connections[connid]->create_reverse_session((const char *)service, (const char *)&startcmd, ! msg->request_id, interface, macaddr) == -1) { --- 1112,1116 ---- if (connections[connid]->create_reverse_session((const char *)service, (const char *)&startcmd, ! dn_ntohs(msg->request_id), interface, macaddr) == -1) { Index: session.cc =================================================================== RCS file: /cvsroot/linux-decnet/latd/session.cc,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** session.cc 5 Apr 2003 10:01:22 -0000 1.37 --- session.cc 5 Apr 2003 11:13:39 -0000 1.38 *************** *** 442,445 **** --- 442,460 ---- } + + // Add in the request ID for reverse connections + if (request_id) + { + if (ptr%1) ptr++; + debuglog(("Sending request id %d, and port %s\n", request_id, ptyname)); + buf[ptr++] = 2; // Parameter number + buf[ptr++] = 2; // Length of the short int + buf[ptr++] = request_id & 0xFF; + buf[ptr++] = request_id >> 8; + + buf[ptr++] = 5; + add_string(buf, &ptr, (unsigned char *)ptyname); + } + // Send message... reply->header.cmd = LAT_CCMD_SESSION; *************** *** 490,493 **** --- 505,509 ---- credit--; } + if (parent.isClient()) parent.queue_message(buf, ptr); Index: reversesession.h =================================================================== RCS file: /cvsroot/linux-decnet/latd/reversesession.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** reversesession.h 5 Apr 2003 10:01:23 -0000 1.1 --- reversesession.h 5 Apr 2003 11:13:39 -0000 1.2 *************** *** 25,29 **** char *service, char *port, unsigned char c); ! protected: --- 25,29 ---- char *service, char *port, unsigned char c); ! void set_request_id(unsigned short id) {request_id = id;} protected: Index: session.h =================================================================== RCS file: /cvsroot/linux-decnet/latd/session.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** session.h 5 Apr 2003 10:01:23 -0000 1.11 --- session.h 5 Apr 2003 11:13:39 -0000 1.12 *************** *** 12,15 **** --- 12,16 ---- clean(_clean), credit(0), + request_id(0), stopped(false), remote_credit(0) *************** *** 52,55 **** --- 53,57 ---- bool clean; // Connection should be 8bit clean char ltaname[255]; + unsigned short request_id; // Flow control Index: TODO =================================================================== RCS file: /cvsroot/linux-decnet/latd/TODO,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** TODO 21 Dec 2002 12:19:42 -0000 1.14 --- TODO 5 Apr 2003 11:13:39 -0000 1.15 *************** *** 2,5 **** --- 2,7 ---- ---- + - Support queued reverse-LAT connections + - support limited reverse LAT connections (command-line already there) - Test service responder. - Find out we send so many more packets than Tru64. Probably related |