/*
* Learn topology from path fields
*/
-void network_learn_topology(char *node, char *path, NetMap *the_netmap, int *netmap_changed) {
+static void network_learn_topology(char *node, char *path, NetMap **the_netmap, int *netmap_changed)
+{
char nexthop[256];
NetMap *nmptr;
- strcpy(nexthop, "");
+ *nexthop = '\0';
if (num_tokens(path, '!') < 3) return;
- for (nmptr = the_netmap; nmptr != NULL; nmptr = nmptr->next) {
+ for (nmptr = *the_netmap; nmptr != NULL; nmptr = nmptr->next) {
if (!strcasecmp(nmptr->nodename, node)) {
extract_token(nmptr->nexthop, path, 0, '!', sizeof nmptr->nexthop);
nmptr->lastcontact = time(NULL);
strcpy(nmptr->nodename, node);
nmptr->lastcontact = time(NULL);
extract_token(nmptr->nexthop, path, 0, '!', sizeof nmptr->nexthop);
- nmptr->next = the_netmap;
- the_netmap = nmptr;
+ nmptr->next = *the_netmap;
+ *the_netmap = nmptr;
(*netmap_changed) ++;
}
/*
* Batch up and send all outbound traffic from the current room
*/
-void network_spoolout_room(char *room_to_spool,
+void network_spoolout_room(RoomProcList *room_to_spool,
char *working_ignetcfg,
NetMap *the_netmap)
{
* Normally this should never happen, but once in a while maybe a room gets
* queued for networking and then deleted before it can happen.
*/
- if (CtdlGetRoom(&CC->room, room_to_spool) != 0) {
- syslog(LOG_CRIT, "ERROR: cannot load <%s>\n", room_to_spool);
+ if (CtdlGetRoom(&CC->room, room_to_spool->name) != 0) {
+ syslog(LOG_CRIT, "ERROR: cannot load <%s>\n", room_to_spool->name);
return;
}
* Process a buffer containing a single message from a single file
* from the inbound queue
*/
-void network_process_buffer(char *buffer, long size, char *working_ignetcfg, NetMap *the_netmap, int *netmap_changed)
+void network_process_buffer(char *buffer, long size, char *working_ignetcfg, NetMap **the_netmap, int *netmap_changed)
{
struct CtdlMessage *msg = NULL;
long pos;
NULL,
msg->cm_fields['D'],
working_ignetcfg,
- the_netmap) == 0)
+ *the_netmap) == 0)
{
/* prepend our node to the path */
if (msg->cm_fields['P'] != NULL) {
long msgstart,
long msgend,
char *working_ignetcfg,
- NetMap *the_netmap,
+ NetMap **the_netmap,
int *netmap_changed)
{
long hold_pos;
*/
void network_process_file(char *filename,
char *working_ignetcfg,
- NetMap *the_netmap,
+ NetMap **the_netmap,
int *netmap_changed)
{
FILE *fp;
/*
* Process anything in the inbound queue
*/
-void network_do_spoolin(char *working_ignetcfg, NetMap *the_netmap, int *netmap_changed)
+void network_do_spoolin(char *working_ignetcfg, NetMap **the_netmap, int *netmap_changed)
{
DIR *dp;
struct dirent *d;
char filename[PATH_MAX];
char cmd[PATH_MAX];
char nexthop[256];
+ long nexthoplen;
int i;
char *ptr;
&& (strcmp(d->d_name, ".."))
&& (strchr(d->d_name, '@') != NULL)
) {
- safestrncpy(nexthop, d->d_name, sizeof nexthop);
+ nexthoplen = safestrncpy(nexthop, d->d_name, sizeof nexthop);
ptr = strchr(nexthop, '@');
- if (ptr) *ptr = 0;
+ if (ptr) {
+ *ptr = 0;
+ nexthoplen = ptr - nexthop;
+ }
snprintf(filename,
sizeof filename,
);
syslog(LOG_DEBUG, "Consolidate %s to %s\n", filename, nexthop);
- if (network_talking_to(nexthop, NTT_CHECK)) {
+ if (network_talking_to(nexthop, nexthoplen, NTT_CHECK)) {
syslog(LOG_DEBUG,
"Currently online with %s - skipping for now\n",
nexthop
);
}
else {
- network_talking_to(nexthop, NTT_ADD);
+ network_talking_to(nexthop, nexthoplen, NTT_ADD);
snprintf(cmd, sizeof cmd, "/bin/cat %s >>%s/%s && /bin/rm -f %s",
filename,
ctdl_netout_dir, nexthop,
filename
);
system(cmd);
- network_talking_to(nexthop, NTT_REMOVE);
+ network_talking_to(nexthop, nexthoplen, NTT_REMOVE);
}
}
}
while (d = readdir(dp), d != NULL) {
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
continue;
- ptr = strchr(d->d_name, '@');
- if (d != NULL)
- continue;
+
snprintf(filename,
sizeof filename,
"%s/%s",
if (!threading)
{
create_spool_dirs();
- CtdlRegisterCleanupHook(destroy_network_queue_room);
+//////todo CtdlRegisterCleanupHook(destroy_network_queue_room);
}
return "network_spool";
}