Changed router code for local destinations
This commit is contained in:
parent
5ca54153c0
commit
ac709b7eda
@ -30,7 +30,9 @@ v0.35.03 06-Jul-2002
|
|||||||
When a new tic area was created the first file received for
|
When a new tic area was created the first file received for
|
||||||
that area was refused.
|
that area was refused.
|
||||||
Fixed a few problems with local UUCP created netmails.
|
Fixed a few problems with local UUCP created netmails.
|
||||||
Added very experimental routing table.
|
* Added very experimental routing table.
|
||||||
|
* Test for local node moved in sequence, testing is now done
|
||||||
|
so as real routing will be done.
|
||||||
|
|
||||||
newuser:
|
newuser:
|
||||||
Check for Unix accounts is now case sensitive.
|
Check for Unix accounts is now case sensitive.
|
||||||
|
@ -56,7 +56,20 @@ typedef enum {E_NOISP, E_TMPISP, E_PRMISP} EMODE;
|
|||||||
typedef enum {AREAMGR, FILEMGR, EMAIL} SERVICE;
|
typedef enum {AREAMGR, FILEMGR, EMAIL} SERVICE;
|
||||||
typedef enum {FEEDINN, FEEDRNEWS, FEEDUUCP} NEWSFEED;
|
typedef enum {FEEDINN, FEEDRNEWS, FEEDUUCP} NEWSFEED;
|
||||||
typedef enum {S_DIRECT, S_DIR, S_FTP} SESSIONTYPE;
|
typedef enum {S_DIRECT, S_DIR, S_FTP} SESSIONTYPE;
|
||||||
typedef enum {RT_ROUTE, RT_DIRECT, RT_DEFAULT, RT_REDIRECT, RT_BOUNCE, RT_CC} ROUTER;
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Routing definitions
|
||||||
|
*/
|
||||||
|
#define R_NOROUTE 0 /* No route descision made */
|
||||||
|
#define R_ROUTE 1 /* Route to destination */
|
||||||
|
#define R_DIRECT 2 /* Direct route */
|
||||||
|
#define R_REDIRECT 3 /* Redirect to new address */
|
||||||
|
#define R_BOUNCE 4 /* Bounce back to sender */
|
||||||
|
#define R_CC 5 /* Make a CC */
|
||||||
|
#define R_LOCAL 6 /* Local destination */
|
||||||
|
#define R_UNLISTED 7 /* Unlisted destination */
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -371,6 +371,8 @@ int main(int argc, char **argv)
|
|||||||
Help();
|
Help();
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
cmd = xstrcat(cmd, (char *)" ");
|
||||||
|
cmd = xstrcat(cmd, argv[i]);
|
||||||
}
|
}
|
||||||
} else if (strncmp(tl(argv[i]), "to", 2) == 0)
|
} else if (strncmp(tl(argv[i]), "to", 2) == 0)
|
||||||
do_toss = TRUE;
|
do_toss = TRUE;
|
||||||
|
371
mbfido/tracker.c
371
mbfido/tracker.c
@ -44,6 +44,17 @@
|
|||||||
extern char nodes_fil[81];
|
extern char nodes_fil[81];
|
||||||
extern long nodes_pos;
|
extern long nodes_pos;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Internal prototypes
|
||||||
|
*/
|
||||||
|
void ParseMask(char *, fidoaddr *);
|
||||||
|
char *get_routetype(int);
|
||||||
|
int GetTableRoute(char *, fidoaddr *);
|
||||||
|
int IsLocal(char *, fidoaddr *);
|
||||||
|
int GetRoute(char *, fidoaddr *);
|
||||||
|
int AreWeHost(faddr *);
|
||||||
|
int AreWeHub(faddr *);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -52,7 +63,6 @@ extern long nodes_pos;
|
|||||||
* syntax is checked in mbsetup.
|
* syntax is checked in mbsetup.
|
||||||
* Matched values return the actual value, the "All" masks return 65535.
|
* Matched values return the actual value, the "All" masks return 65535.
|
||||||
*/
|
*/
|
||||||
void ParseMask(char *, fidoaddr *);
|
|
||||||
void ParseMask(char *s, fidoaddr *addr)
|
void ParseMask(char *s, fidoaddr *addr)
|
||||||
{
|
{
|
||||||
char *buf, *str, *p;
|
char *buf, *str, *p;
|
||||||
@ -133,6 +143,135 @@ void ParseMask(char *s, fidoaddr *addr)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char *get_routetype(int val)
|
||||||
|
{
|
||||||
|
switch (val) {
|
||||||
|
case R_NOROUTE: return (char *)"Default route";
|
||||||
|
case R_ROUTE: return (char *)"Route to";
|
||||||
|
case R_DIRECT: return (char *)"Direct";
|
||||||
|
case R_REDIRECT: return (char *)"New address";
|
||||||
|
case R_BOUNCE: return (char *)"Bounce";
|
||||||
|
case R_CC: return (char *)"CarbonCopy ";
|
||||||
|
case R_LOCAL: return (char *)"Local aka";
|
||||||
|
case R_UNLISTED: return (char *)"Unlisted";
|
||||||
|
default: return (char *)"Internal error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int GetTableRoute(char *ftn, fidoaddr *res)
|
||||||
|
{
|
||||||
|
char *temp;
|
||||||
|
faddr *dest;
|
||||||
|
fidoaddr mask;
|
||||||
|
int match, last;
|
||||||
|
long ptr;
|
||||||
|
FILE *fil;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check routing table
|
||||||
|
*/
|
||||||
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
sprintf(temp, "%s/etc/route.data", getenv("MBSE_ROOT"));
|
||||||
|
if ((fil = fopen(temp, "r")) == NULL) {
|
||||||
|
free(temp);
|
||||||
|
return R_NOROUTE;
|
||||||
|
}
|
||||||
|
free(temp);
|
||||||
|
fread(&routehdr, sizeof(routehdr), 1, fil);
|
||||||
|
|
||||||
|
memset(res, 0, sizeof(fidoaddr));
|
||||||
|
dest = parsefnode(ftn);
|
||||||
|
if (SearchFidonet(dest->zone)) {
|
||||||
|
if (dest->domain)
|
||||||
|
free(dest->domain);
|
||||||
|
dest->domain = xstrcpy(fidonet.domain);
|
||||||
|
}
|
||||||
|
Syslog('r', "Get table route for: %s", ascfnode(dest, 0xff));
|
||||||
|
|
||||||
|
match = last = METRIC_MAX;
|
||||||
|
ptr = ftell(fil);
|
||||||
|
|
||||||
|
while (fread(&route, routehdr.recsize, 1, fil) == 1) {
|
||||||
|
if (route.Active) {
|
||||||
|
ParseMask(route.mask, &mask);
|
||||||
|
Syslog('r', "Table %s (%s) => %s", route.mask, get_routetype(route.routetype), aka2str(route.dest));
|
||||||
|
match = METRIC_MAX;
|
||||||
|
if (mask.zone) {
|
||||||
|
if ((mask.zone == 65535) || (mask.zone == dest->zone)) {
|
||||||
|
match = METRIC_ZONE;
|
||||||
|
if ((mask.net == 65535) || (mask.net == dest->net)) {
|
||||||
|
match = METRIC_NET;
|
||||||
|
if ((mask.node == 65535) || (mask.node == dest->node)) {
|
||||||
|
match = METRIC_NODE;
|
||||||
|
if ((mask.point == 65535) || (mask.point == dest->point))
|
||||||
|
match = METRIC_POINT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (match < last) {
|
||||||
|
Syslog('r', "Best util now");
|
||||||
|
last = match;
|
||||||
|
ptr = ftell(fil) - routehdr.recsize;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Syslog('!', "Warning, internal error in routing table");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tidy_faddr(dest);
|
||||||
|
|
||||||
|
if (last < METRIC_MAX) {
|
||||||
|
fseek(fil, ptr, SEEK_SET);
|
||||||
|
fread(&route, routehdr.recsize, 1, fil);
|
||||||
|
fclose(fil);
|
||||||
|
Syslog('r', "Route selected %s %s %s", route.mask, get_routetype(route.routetype), aka2str(route.dest));
|
||||||
|
memcpy(res, &route.dest, sizeof(fidoaddr));
|
||||||
|
return route.routetype;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fil);
|
||||||
|
return R_NOROUTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if destination is one of our local aka's
|
||||||
|
*/
|
||||||
|
int IsLocal(char *ftn, fidoaddr *res)
|
||||||
|
{
|
||||||
|
faddr *dest;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
memset(res, 0, sizeof(fidoaddr));
|
||||||
|
dest = parsefnode(ftn);
|
||||||
|
if (SearchFidonet(dest->zone)) {
|
||||||
|
if (dest->domain)
|
||||||
|
free(dest->domain);
|
||||||
|
dest->domain = xstrcpy(fidonet.domain);
|
||||||
|
}
|
||||||
|
Syslog('r', "Check local aka for: %s", ascfnode(dest, 0xff));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if the destination is ourself.
|
||||||
|
*/
|
||||||
|
for (i = 0; i < 40; i++) {
|
||||||
|
if (CFG.akavalid[i] && (CFG.aka[i].zone == dest->zone) && (CFG.aka[i].net == dest->net) &&
|
||||||
|
(CFG.aka[i].node == dest->node) && (dest->point == CFG.aka[i].point)) {
|
||||||
|
Syslog('+', "R: %s => Loc %s", ascfnode(dest, 0x0f), aka2str(CFG.aka[i]));
|
||||||
|
memcpy(res, &CFG.aka[i], sizeof(fidoaddr));
|
||||||
|
tidy_faddr(dest);
|
||||||
|
return R_LOCAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return R_NOROUTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Netmail tracker. Return TRUE if we found a valid route.
|
* Netmail tracker. Return TRUE if we found a valid route.
|
||||||
* If we did find a route, it is returned in the route pointer.
|
* If we did find a route, it is returned in the route pointer.
|
||||||
@ -142,9 +281,34 @@ void ParseMask(char *s, fidoaddr *addr)
|
|||||||
int TrackMail(fidoaddr too, fidoaddr *routeto)
|
int TrackMail(fidoaddr too, fidoaddr *routeto)
|
||||||
{
|
{
|
||||||
int rc, i;
|
int rc, i;
|
||||||
|
char *tstr;
|
||||||
|
|
||||||
Syslog('r', "Tracking destination %s", aka2str(too));
|
Syslog('r', "Tracking destination to %s", aka2str(too));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check for local destination
|
||||||
|
*/
|
||||||
|
rc = IsLocal(aka2str(too) , routeto);
|
||||||
|
if (rc == R_LOCAL) {
|
||||||
|
// FIXME: When R_CC implemented check table for Cc:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check route table
|
||||||
|
*/
|
||||||
|
tstr = xstrcpy(aka2str(too));
|
||||||
|
rc = GetTableRoute(aka2str(too), routeto);
|
||||||
|
if (rc != R_NOROUTE) {
|
||||||
|
Syslog('+', "R: %s Routing table: %s => %s", tstr, get_routetype(rc), aka2str(*routeto));
|
||||||
|
free(tstr);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
free(tstr);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If no descision yet, get default routing
|
||||||
|
*/
|
||||||
rc = GetRoute(aka2str(too) , routeto);
|
rc = GetRoute(aka2str(too) , routeto);
|
||||||
if (rc == R_NOROUTE) {
|
if (rc == R_NOROUTE) {
|
||||||
WriteError("No route to %s, not parsed", aka2str(too));
|
WriteError("No route to %s, not parsed", aka2str(too));
|
||||||
@ -155,27 +319,19 @@ int TrackMail(fidoaddr too, fidoaddr *routeto)
|
|||||||
return R_UNLISTED;
|
return R_UNLISTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* If local aka
|
|
||||||
*/
|
|
||||||
if (rc == R_LOCAL)
|
|
||||||
return R_LOCAL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now look again if from the routing result we find a
|
* Now look again if from the routing result we find a
|
||||||
* direct link. If so, maybe adjust something.
|
* direct link. If so, maybe adjust something.
|
||||||
*/
|
*/
|
||||||
if (SearchNode(*routeto)) {
|
if (SearchNode(*routeto)) {
|
||||||
Syslog('r', "Known node: %s", aka2str(nodes.Aka[0]));
|
Syslog('r', "Node is in setup: %s", aka2str(nodes.Aka[0]));
|
||||||
Syslog('r', "Check \"too\" %s", aka2str(too));
|
|
||||||
|
|
||||||
if (nodes.RouteVia.zone) {
|
if (nodes.RouteVia.zone) {
|
||||||
|
Syslog('r', "Using RouteVia address %s", aka2str(nodes.RouteVia));
|
||||||
routeto->zone = nodes.RouteVia.zone;
|
routeto->zone = nodes.RouteVia.zone;
|
||||||
routeto->net = nodes.RouteVia.net;
|
routeto->net = nodes.RouteVia.net;
|
||||||
routeto->node = nodes.RouteVia.node;
|
routeto->node = nodes.RouteVia.node;
|
||||||
routeto->point = nodes.RouteVia.point;
|
routeto->point = nodes.RouteVia.point;
|
||||||
sprintf(routeto->domain, "%s", nodes.RouteVia.domain);
|
sprintf(routeto->domain, "%s", nodes.RouteVia.domain);
|
||||||
return R_ROUTE;
|
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < 20; i++)
|
for (i = 0; i < 20; i++)
|
||||||
if (routeto->zone == nodes.Aka[i].zone)
|
if (routeto->zone == nodes.Aka[i].zone)
|
||||||
@ -185,8 +341,9 @@ int TrackMail(fidoaddr too, fidoaddr *routeto)
|
|||||||
routeto->node = nodes.Aka[i].node;
|
routeto->node = nodes.Aka[i].node;
|
||||||
routeto->point = nodes.Aka[i].point;
|
routeto->point = nodes.Aka[i].point;
|
||||||
sprintf(routeto->domain, "%s", nodes.Aka[i].domain);
|
sprintf(routeto->domain, "%s", nodes.Aka[i].domain);
|
||||||
return R_ROUTE;
|
|
||||||
}
|
}
|
||||||
|
Syslog('r', "Final routing to: %s", aka2str(*routeto));
|
||||||
|
return R_ROUTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
@ -194,7 +351,6 @@ int TrackMail(fidoaddr too, fidoaddr *routeto)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int AreWeHost(faddr *);
|
|
||||||
int AreWeHost(faddr *dest)
|
int AreWeHost(faddr *dest)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -220,7 +376,6 @@ int AreWeHost(faddr *dest)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int AreWeHub(faddr *);
|
|
||||||
int AreWeHub(faddr *dest)
|
int AreWeHub(faddr *dest)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -266,13 +421,9 @@ int GetRoute(char *ftn, fidoaddr *res)
|
|||||||
node *dnlent, *bnlent;
|
node *dnlent, *bnlent;
|
||||||
unsigned short myregion;
|
unsigned short myregion;
|
||||||
faddr *dest, *best, *maddr;
|
faddr *dest, *best, *maddr;
|
||||||
fidoaddr *fido, mask;
|
fidoaddr *fido, dir;
|
||||||
int me_host = -1, me_hub = -1;
|
int me_host = -1, me_hub = -1, i;
|
||||||
int i, match, last;
|
|
||||||
fidoaddr dir;
|
|
||||||
FILE *fil;
|
FILE *fil;
|
||||||
char *temp;
|
|
||||||
long ptr;
|
|
||||||
|
|
||||||
memset(res, 0, sizeof(fidoaddr));
|
memset(res, 0, sizeof(fidoaddr));
|
||||||
dest = parsefnode(ftn);
|
dest = parsefnode(ftn);
|
||||||
@ -282,99 +433,15 @@ int GetRoute(char *ftn, fidoaddr *res)
|
|||||||
dest->domain = xstrcpy(fidonet.domain);
|
dest->domain = xstrcpy(fidonet.domain);
|
||||||
}
|
}
|
||||||
best = bestaka_s(dest);
|
best = bestaka_s(dest);
|
||||||
Syslog('r', "Get route for: %s", ascfnode(dest, 0xff));
|
Syslog('r', "Get def. route for : %s", ascfnode(dest, 0xff));
|
||||||
Syslog('r', "Our best aka is : %s", ascfnode(best, 0xff));
|
Syslog('r', "Our best aka is : %s", ascfnode(best, 0xff));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check routing table
|
* Check if the destination our point.
|
||||||
*/
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
|
||||||
sprintf(temp, "%s/etc/route.data", getenv("MBSE_ROOT"));
|
|
||||||
if ((fil = fopen(temp, "r")) != NULL) {
|
|
||||||
fread(&routehdr, sizeof(routehdr), 1, fil);
|
|
||||||
|
|
||||||
match = last = METRIC_MAX;
|
|
||||||
ptr = ftell(fil);
|
|
||||||
|
|
||||||
while (fread(&route, routehdr.recsize, 1, fil) == 1) {
|
|
||||||
if (route.Active) {
|
|
||||||
ParseMask(route.mask, &mask);
|
|
||||||
Syslog('r', "Table %s => %s", route.mask, aka2str(route.dest));
|
|
||||||
match = METRIC_MAX;
|
|
||||||
if (mask.zone) {
|
|
||||||
if ((mask.zone == 65535) || (mask.zone == dest->zone)) {
|
|
||||||
match = METRIC_ZONE;
|
|
||||||
if ((mask.net == 65535) || (mask.net == dest->net)) {
|
|
||||||
match = METRIC_NET;
|
|
||||||
if ((mask.node == 65535) || (mask.node == dest->node)) {
|
|
||||||
match = METRIC_NODE;
|
|
||||||
if ((mask.point == 65535) || (mask.point == dest->point))
|
|
||||||
match = METRIC_POINT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (match < last) {
|
|
||||||
Syslog('r', "Best util now");
|
|
||||||
last = match;
|
|
||||||
ptr = ftell(fil) - routehdr.recsize;
|
|
||||||
}
|
|
||||||
switch (match) {
|
|
||||||
case METRIC_MAX: Syslog('r', "Match MAX");
|
|
||||||
break;
|
|
||||||
case METRIC_ZONE: Syslog('r', "Match ZONE");
|
|
||||||
break;
|
|
||||||
case METRIC_NET: Syslog('r', "Match NET");
|
|
||||||
break;
|
|
||||||
case METRIC_NODE: Syslog('r', "Match NODE");
|
|
||||||
break;
|
|
||||||
case METRIC_POINT: Syslog('r', "Match POINT");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Syslog('r', "Error in table");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (last < METRIC_MAX) {
|
|
||||||
fseek(fil, ptr, SEEK_SET);
|
|
||||||
fread(&route, routehdr.recsize, 1, fil);
|
|
||||||
fclose(fil);
|
|
||||||
Syslog('r', "Route selected %s %d %s", route.mask, route.routetype, aka2str(route.dest));
|
|
||||||
/*
|
|
||||||
* Found a route record that matches. Return to caller with the result except
|
|
||||||
* when the result is RT_DEFAULT, which means fall down to the default router below.
|
|
||||||
* This is also true for routes that don't match at all.
|
|
||||||
*/
|
|
||||||
if (route.routetype == RT_ROUTE) {
|
|
||||||
Syslog('+', "R: %s Routing table: Route => %s", ascfnode(dest, 0xff), aka2str(route.dest));
|
|
||||||
memcpy(res, &route.dest, sizeof(fidoaddr));
|
|
||||||
return R_ROUTE;
|
|
||||||
}
|
|
||||||
if (route.routetype == RT_DIRECT) {
|
|
||||||
Syslog('+', "R: %s Routing table: Direct => %s", ascfnode(dest, 0xff), aka2str(route.dest));
|
|
||||||
memcpy(res, &route.dest, sizeof(fidoaddr));
|
|
||||||
return R_DIRECT;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fclose(fil);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(temp);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if the destination is ourself.
|
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < 40; i++) {
|
for (i = 0; i < 40; i++) {
|
||||||
if (CFG.akavalid[i] && (CFG.aka[i].zone == dest->zone) &&
|
if (CFG.akavalid[i] &&
|
||||||
(CFG.aka[i].net == dest->net) && (CFG.aka[i].node == dest->node)) {
|
(CFG.aka[i].zone == dest->zone) && (CFG.aka[i].net == dest->net) && (CFG.aka[i].node == dest->node)) {
|
||||||
if (dest->point == CFG.aka[i].point) {
|
|
||||||
Syslog('+', "R: %s => Loc %s", ascfnode(dest, 0x0f), aka2str(CFG.aka[i]));
|
|
||||||
memcpy(res, &CFG.aka[i], sizeof(fidoaddr));
|
|
||||||
tidy_faddr(best);
|
|
||||||
tidy_faddr(dest);
|
|
||||||
return R_LOCAL;
|
|
||||||
}
|
|
||||||
if (dest->point && (!CFG.aka[i].point)) {
|
if (dest->point && (!CFG.aka[i].point)) {
|
||||||
Syslog('+', "R: %s => My point", ascfnode(dest, 0xff));
|
Syslog('+', "R: %s => My point", ascfnode(dest, 0xff));
|
||||||
fido = faddr2fido(dest);
|
fido = faddr2fido(dest);
|
||||||
@ -418,10 +485,8 @@ int GetRoute(char *ftn, fidoaddr *res)
|
|||||||
Syslog('r', "Checking for a direct link, 4d");
|
Syslog('r', "Checking for a direct link, 4d");
|
||||||
if (SearchNode(dir)) {
|
if (SearchNode(dir)) {
|
||||||
for (i = 0; i < 20; i++) {
|
for (i = 0; i < 20; i++) {
|
||||||
if ((dir.zone == nodes.Aka[i].zone) &&
|
if ((dir.zone == nodes.Aka[i].zone) && (dir.node == nodes.Aka[i].node) &&
|
||||||
(dir.node == nodes.Aka[i].node) &&
|
(dir.net == nodes.Aka[i].net) && (dir.point == nodes.Aka[i].point)) {
|
||||||
(dir.net == nodes.Aka[i].net) &&
|
|
||||||
(dir.point == nodes.Aka[i].point)) {
|
|
||||||
memcpy(res, &nodes.Aka[i], sizeof(fidoaddr));
|
memcpy(res, &nodes.Aka[i], sizeof(fidoaddr));
|
||||||
Syslog('+', "R: %s => Dir link %s", ascfnode(dest, 0x0f), aka2str(*res));
|
Syslog('+', "R: %s => Dir link %s", ascfnode(dest, 0x0f), aka2str(*res));
|
||||||
tidy_faddr(best);
|
tidy_faddr(best);
|
||||||
@ -438,9 +503,7 @@ int GetRoute(char *ftn, fidoaddr *res)
|
|||||||
dir.point = 0;
|
dir.point = 0;
|
||||||
if (SearchNode(dir)) {
|
if (SearchNode(dir)) {
|
||||||
for (i = 0; i < 20; i++) {
|
for (i = 0; i < 20; i++) {
|
||||||
if ((dir.zone == nodes.Aka[i].zone) &&
|
if ((dir.zone == nodes.Aka[i].zone) && (dir.node == nodes.Aka[i].node) && (dir.net == nodes.Aka[i].net)) {
|
||||||
(dir.node == nodes.Aka[i].node) &&
|
|
||||||
(dir.net == nodes.Aka[i].net)) {
|
|
||||||
memcpy(res, &nodes.Aka[i], sizeof(fidoaddr));
|
memcpy(res, &nodes.Aka[i], sizeof(fidoaddr));
|
||||||
res->point = 0;
|
res->point = 0;
|
||||||
Syslog('+', "R: %s => Boss link %s", ascfnode(dest, 0x0f), aka2str(*res));
|
Syslog('+', "R: %s => Boss link %s", ascfnode(dest, 0x0f), aka2str(*res));
|
||||||
@ -465,9 +528,7 @@ int GetRoute(char *ftn, fidoaddr *res)
|
|||||||
dir.net = dnlent->upnet;
|
dir.net = dnlent->upnet;
|
||||||
if (SearchNode(dir)) {
|
if (SearchNode(dir)) {
|
||||||
for (i = 0; i < 20; i++) {
|
for (i = 0; i < 20; i++) {
|
||||||
if ((dir.zone == nodes.Aka[i].zone) &&
|
if ((dir.zone == nodes.Aka[i].zone) && (dir.node == nodes.Aka[i].node) && (dir.net == nodes.Aka[i].net)) {
|
||||||
(dir.node == nodes.Aka[i].node) &&
|
|
||||||
(dir.net == nodes.Aka[i].net)) {
|
|
||||||
memcpy(res, &nodes.Aka[i], sizeof(fidoaddr));
|
memcpy(res, &nodes.Aka[i], sizeof(fidoaddr));
|
||||||
res->point = 0;
|
res->point = 0;
|
||||||
Syslog('+', "R: %s => Uplink %s", ascfnode(dest, 0x0f), aka2str(*res));
|
Syslog('+', "R: %s => Uplink %s", ascfnode(dest, 0x0f), aka2str(*res));
|
||||||
@ -501,8 +562,7 @@ int GetRoute(char *ftn, fidoaddr *res)
|
|||||||
if (me_host != -1) {
|
if (me_host != -1) {
|
||||||
Syslog('r', "We are a host");
|
Syslog('r', "We are a host");
|
||||||
sprintf(res->domain, "%s", CFG.aka[me_host].domain);
|
sprintf(res->domain, "%s", CFG.aka[me_host].domain);
|
||||||
if (((myregion != dnlent->region) && (!(dnlent->pflag & NL_DUMMY))) ||
|
if (((myregion != dnlent->region) && (!(dnlent->pflag & NL_DUMMY))) || (CFG.aka[me_host].zone != dest->zone)) {
|
||||||
(CFG.aka[me_host].zone != dest->zone)) {
|
|
||||||
res->zone = CFG.aka[me_host].zone;
|
res->zone = CFG.aka[me_host].zone;
|
||||||
res->net = myregion;
|
res->net = myregion;
|
||||||
Syslog('+', "R: %s => Region %s", ascfnode(dest, 0x0f), aka2str(*res));
|
Syslog('+', "R: %s => Region %s", ascfnode(dest, 0x0f), aka2str(*res));
|
||||||
@ -556,8 +616,7 @@ int GetRoute(char *ftn, fidoaddr *res)
|
|||||||
if (me_hub != -1) {
|
if (me_hub != -1) {
|
||||||
Syslog('r', "We are a hub");
|
Syslog('r', "We are a hub");
|
||||||
sprintf(res->domain, "%s", CFG.aka[me_hub].domain);
|
sprintf(res->domain, "%s", CFG.aka[me_hub].domain);
|
||||||
if ((dnlent->upnode == CFG.aka[me_hub].node) &&
|
if ((dnlent->upnode == CFG.aka[me_hub].node) && (dnlent->upnet == CFG.aka[me_hub].net) &&
|
||||||
(dnlent->upnet == CFG.aka[me_hub].net) &&
|
|
||||||
(dnlent->addr.zone == CFG.aka[me_hub].zone)) {
|
(dnlent->addr.zone == CFG.aka[me_hub].zone)) {
|
||||||
res->zone = dest->zone;
|
res->zone = dest->zone;
|
||||||
res->net = dest->net;
|
res->net = dest->net;
|
||||||
@ -616,16 +675,13 @@ int GetRoute(char *ftn, fidoaddr *res)
|
|||||||
while (fread(&nodes, nodeshdr.recsize, 1, fil) == 1) {
|
while (fread(&nodes, nodeshdr.recsize, 1, fil) == 1) {
|
||||||
fseek(fil, nodeshdr.filegrp + nodeshdr.mailgrp, SEEK_CUR);
|
fseek(fil, nodeshdr.filegrp + nodeshdr.mailgrp, SEEK_CUR);
|
||||||
for (i = 0; i < 20; i++) {
|
for (i = 0; i < 20; i++) {
|
||||||
if ((nodes.Aka[i].zone) &&
|
if ((nodes.Aka[i].zone) && (nodes.Aka[i].zone == best->zone) && (nodes.Aka[i].net == best->net)) {
|
||||||
(nodes.Aka[i].zone == best->zone) &&
|
|
||||||
(nodes.Aka[i].net == best->net)) {
|
|
||||||
maddr = fido2faddr(nodes.Aka[i]);
|
maddr = fido2faddr(nodes.Aka[i]);
|
||||||
bnlent = getnlent(maddr);
|
bnlent = getnlent(maddr);
|
||||||
tidy_faddr(maddr);
|
tidy_faddr(maddr);
|
||||||
if (bnlent->addr.domain)
|
if (bnlent->addr.domain)
|
||||||
free(bnlent->addr.domain);
|
free(bnlent->addr.domain);
|
||||||
if ((bnlent->type == NL_HUB) ||
|
if ((bnlent->type == NL_HUB) || (bnlent->type == NL_HOST)) {
|
||||||
(bnlent->type == NL_HOST)) {
|
|
||||||
fclose(fil);
|
fclose(fil);
|
||||||
memcpy(res, &nodes.Aka[i], sizeof(fidoaddr));
|
memcpy(res, &nodes.Aka[i], sizeof(fidoaddr));
|
||||||
Syslog('r', "R: %s => %s", ascfnode(dest, 0xff), aka2str(*res));
|
Syslog('r', "R: %s => %s", ascfnode(dest, 0xff), aka2str(*res));
|
||||||
@ -648,53 +704,24 @@ int GetRoute(char *ftn, fidoaddr *res)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TestRoute(char *dest)
|
|
||||||
{
|
|
||||||
fidoaddr result;
|
|
||||||
int rc;
|
|
||||||
char *res;
|
|
||||||
|
|
||||||
rc = GetRoute(dest, &result);
|
|
||||||
switch (rc) {
|
|
||||||
case R_NOROUTE: res = xstrcpy((char *)"No Route");
|
|
||||||
break;
|
|
||||||
case R_LOCAL: res = xstrcpy((char *)"Local address");
|
|
||||||
break;
|
|
||||||
case R_DIRECT: res = xstrcpy((char *)"Direct link");
|
|
||||||
break;
|
|
||||||
case R_ROUTE: res = xstrcpy((char *)"Routed");
|
|
||||||
break;
|
|
||||||
case R_UNLISTED: res = xstrcpy((char *)"Unlisted node");
|
|
||||||
break;
|
|
||||||
default: res = xstrcpy((char *)"Internal error");
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Route %s => %s, route result: %s\n", dest, aka2str(result), res);
|
|
||||||
free(res);
|
|
||||||
|
|
||||||
if ((rc == R_NOROUTE) || (rc == R_UNLISTED) || (rc == R_LOCAL))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (SearchNode(result)) {
|
|
||||||
if (nodes.RouteVia.zone)
|
|
||||||
printf("Node is in the setup, route via is %s\n", aka2str(nodes.RouteVia));
|
|
||||||
else
|
|
||||||
printf("Node is in the setup, no route via address\n");
|
|
||||||
} else {
|
|
||||||
printf("Node is not in the setup\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TestTracker(faddr *dest)
|
void TestTracker(faddr *dest)
|
||||||
{
|
{
|
||||||
char *addr;
|
fidoaddr addr, result;
|
||||||
|
int rc;
|
||||||
|
char *too;
|
||||||
|
|
||||||
|
memset(&addr, 0, sizeof(fidoaddr));
|
||||||
|
addr.zone = dest->zone;
|
||||||
|
addr.net = dest->net;
|
||||||
|
addr.node = dest->node;
|
||||||
|
addr.point = dest->point;
|
||||||
|
|
||||||
colour(7, 0);
|
colour(7, 0);
|
||||||
addr = ascfnode(dest, 0x2f);
|
Syslog('+', "Test route to %s", aka2str(addr));
|
||||||
Syslog('+', "Search route for %s", addr);
|
|
||||||
TestRoute(addr);
|
rc = TrackMail(addr, &result);
|
||||||
|
too = xstrcpy(aka2str(addr));
|
||||||
|
printf("Route %s => %s, route result: %s\n", too, aka2str(result), get_routetype(rc));
|
||||||
|
free(too);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,16 +1,9 @@
|
|||||||
#ifndef _TRACKER_H
|
#ifndef _TRACKER_H
|
||||||
#define _TRACKER_H
|
#define _TRACKER_H
|
||||||
|
|
||||||
#define R_NOROUTE 0
|
/* $Id$ */
|
||||||
#define R_LOCAL 1
|
|
||||||
#define R_DIRECT 2
|
|
||||||
#define R_ROUTE 3
|
|
||||||
#define R_UNLISTED 4
|
|
||||||
|
|
||||||
|
|
||||||
int TrackMail(fidoaddr, fidoaddr *);
|
int TrackMail(fidoaddr, fidoaddr *);
|
||||||
int GetRoute(char *, fidoaddr *);
|
|
||||||
void TestTracker(faddr *);
|
void TestTracker(faddr *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1772,12 +1772,12 @@ int edit_sessiontype(int y, int x, int val)
|
|||||||
char *get_routetype(int val)
|
char *get_routetype(int val)
|
||||||
{
|
{
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case RT_ROUTE: return (char *)"Route to ";
|
case R_NOROUTE: return (char *)"Default ";
|
||||||
case RT_DIRECT: return (char *)"Direct ";
|
case R_ROUTE: return (char *)"Route to ";
|
||||||
case RT_DEFAULT: return (char *)"Default ";
|
case R_DIRECT: return (char *)"Direct ";
|
||||||
case RT_REDIRECT: return (char *)"New address";
|
case R_REDIRECT: return (char *)"New address";
|
||||||
case RT_BOUNCE: return (char *)"Bounce ";
|
case R_BOUNCE: return (char *)"Bounce ";
|
||||||
case RT_CC: return (char *)"CarbonCopy ";
|
case R_CC: return (char *)"CarbonCopy ";
|
||||||
default: return NULL;
|
default: return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1804,10 +1804,10 @@ int edit_routetype(int y, int x, int val)
|
|||||||
|
|
||||||
if (ch == ' ') {
|
if (ch == ' ') {
|
||||||
// if (val < RT_CC)
|
// if (val < RT_CC)
|
||||||
if (val < RT_DEFAULT)
|
if (val < R_DIRECT)
|
||||||
val++;
|
val++;
|
||||||
else
|
else
|
||||||
val = RT_ROUTE;
|
val = R_NOROUTE;
|
||||||
}
|
}
|
||||||
} while (ch != KEY_ENTER && ch != '\012');
|
} while (ch != KEY_ENTER && ch != '\012');
|
||||||
set_color(WHITE, BLACK);
|
set_color(WHITE, BLACK);
|
||||||
|
@ -215,7 +215,7 @@ int AppendRoute(void)
|
|||||||
/*
|
/*
|
||||||
* Fill in default values
|
* Fill in default values
|
||||||
*/
|
*/
|
||||||
route.routetype = RT_ROUTE;
|
route.routetype = R_NOROUTE;
|
||||||
fwrite(&route, sizeof(route), 1, fil);
|
fwrite(&route, sizeof(route), 1, fil);
|
||||||
fclose(fil);
|
fclose(fil);
|
||||||
RouteUpdated = 1;
|
RouteUpdated = 1;
|
||||||
|
Reference in New Issue
Block a user