4 * This module will eventually replace netproc and some of its utilities. In
5 * the meantime, it serves as a mailing list manager.
7 * Copyright (C) 2000-2001 by Art Cancro and others.
8 * This code is released under the terms of the GNU General Public License.
13 * FIXME do something about concurrency issues:
14 * 1. Don't allow the two nodes to poll each other at the same time
15 * 2. Don't allow polls during network processing
16 * 3. Kill Bill Gates using either a chainsaw or a wood chipper
27 #include <sys/types.h>
29 #if TIME_WITH_SYS_TIME
30 # include <sys/time.h>
34 # include <sys/time.h>
45 #include "sysdep_decls.h"
46 #include "citserver.h"
49 #include "dynloader.h"
56 #include "internet_addressing.h"
57 #include "serv_network.h"
58 #include "clientsocket.h"
62 * When we do network processing, it's accomplished in two passes; one to
63 * gather a list of rooms and one to actually do them. It's ok that rplist
64 * is global; this process *only* runs as part of the housekeeping loop and
65 * therefore only one will run at a time.
68 struct RoomProcList *next;
69 char name[ROOMNAMELEN];
72 struct RoomProcList *rplist = NULL;
76 * We build a map of the Citadel network during network runs.
85 struct NetMap *the_netmap = NULL;
90 * Read the network map from its configuration file into memory.
92 void read_network_map(void) {
93 char *serialized_map = NULL;
98 serialized_map = CtdlGetSysConfig(IGNETMAP);
99 if (serialized_map == NULL) return; /* if null, no entries */
101 /* Use the string tokenizer to grab one line at a time */
102 for (i=0; i<num_tokens(serialized_map, '\n'); ++i) {
103 extract_token(buf, serialized_map, i, '\n');
104 nmptr = (struct NetMap *) mallok(sizeof(struct NetMap));
105 extract(nmptr->nodename, buf, 0);
106 nmptr->lastcontact = extract_long(buf, 1);
107 extract(nmptr->nexthop, buf, 2);
108 nmptr->next = the_netmap;
112 phree(serialized_map);
117 * Write the network map from memory back to the configuration file.
119 void write_network_map(void) {
120 char *serialized_map = NULL;
121 struct NetMap *nmptr;
123 serialized_map = strdoop("");
125 if (the_netmap != NULL) {
126 for (nmptr = the_netmap; nmptr != NULL; nmptr = nmptr->next) {
127 serialized_map = reallok(serialized_map,
128 (strlen(serialized_map)+SIZ) );
129 if (strlen(nmptr->nodename) > 0) {
130 sprintf(&serialized_map[strlen(serialized_map)],
139 CtdlPutSysConfig(IGNETMAP, serialized_map);
140 phree(serialized_map);
142 /* Now free the list */
143 while (the_netmap != NULL) {
144 nmptr = the_netmap->next;
153 * Check the network map and determine whether the supplied node name is
154 * valid. If it is not a neighbor node, supply the name of a neighbor node
155 * which is the next hop. If it *is* a neighbor node, we also fill in the
158 int is_valid_node(char *nexthop, char *secret, char *node) {
159 char *ignetcfg = NULL;
164 struct NetMap *nmptr;
171 * First try the neighbor nodes
173 ignetcfg = CtdlGetSysConfig(IGNETCFG);
174 if (ignetcfg == NULL) {
175 if (nexthop != NULL) {
182 if (nexthop != NULL) {
186 /* Use the string tokenizer to grab one line at a time */
187 for (i=0; i<num_tokens(ignetcfg, '\n'); ++i) {
188 extract_token(linebuf, ignetcfg, i, '\n');
189 extract(buf, linebuf, 0);
190 if (!strcasecmp(buf, node)) {
191 if (nexthop != NULL) {
194 if (secret != NULL) {
195 extract(secret, linebuf, 1);
203 return(retval); /* yup, it's a direct neighbor */
207 * If we get to this point we have to see if we know the next hop
209 if (the_netmap != NULL) {
210 for (nmptr = the_netmap; nmptr != NULL; nmptr = nmptr->next) {
211 if (!strcasecmp(nmptr->nodename, node)) {
212 if (nexthop != NULL) {
213 strcpy(nexthop, nmptr->nexthop);
221 * If we get to this point, the supplied node name is bogus.
223 lprintf(5, "Invalid node name <%s>\n", node);
231 void cmd_gnet(char *argbuf) {
236 if (CtdlAccessCheck(ac_room_aide)) return;
237 assoc_file_name(filename, &CC->quickroom, "netconfigs");
238 cprintf("%d Network settings for room #%ld <%s>\n",
240 CC->quickroom.QRnumber, CC->quickroom.QRname);
242 fp = fopen(filename, "r");
244 while (fgets(buf, sizeof buf, fp) != NULL) {
245 buf[strlen(buf)-1] = 0;
246 cprintf("%s\n", buf);
255 void cmd_snet(char *argbuf) {
256 char tempfilename[SIZ];
261 if (CtdlAccessCheck(ac_room_aide)) return;
262 safestrncpy(tempfilename, tmpnam(NULL), sizeof tempfilename);
263 assoc_file_name(filename, &CC->quickroom, "netconfigs");
265 fp = fopen(tempfilename, "w");
267 cprintf("%d Cannot open %s: %s\n",
268 ERROR+INTERNAL_ERROR,
273 cprintf("%d %s\n", SEND_LISTING, tempfilename);
274 while (client_gets(buf), strcmp(buf, "000")) {
275 fprintf(fp, "%s\n", buf);
279 /* Now copy the temp file to its permanent location
280 * (We use /bin/mv instead of link() because they may be on
281 * different filesystems)
284 snprintf(buf, sizeof buf, "/bin/mv %s %s", tempfilename, filename);
291 * Spools out one message from the list.
293 void network_spool_msg(long msgnum, void *userdata) {
294 struct SpoolControl *sc;
295 struct namelist *nptr;
299 char *newpath = NULL;
300 size_t instr_len = SIZ;
301 struct CtdlMessage *msg = NULL;
302 struct CtdlMessage *imsg;
303 struct ser_ret sermsg;
309 int delete_after_send = 0; /* Set to 1 to delete after spooling */
311 sc = (struct SpoolControl *)userdata;
314 * Process mailing list recipients
316 if (sc->listrecps != NULL) {
318 /* First, copy it to the spoolout room */
319 err = CtdlSaveMsgPointerInRoom(SMTP_SPOOLOUT_ROOM, msgnum, 0);
320 if (err != 0) return;
323 * Figure out how big a buffer we need to allocate
325 for (nptr = sc->listrecps; nptr != NULL; nptr = nptr->next) {
326 instr_len = instr_len + strlen(nptr->name);
332 lprintf(9, "Generating delivery instructions\n");
333 instr = mallok(instr_len);
335 lprintf(1, "Cannot allocate %d bytes for instr...\n",
340 "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
341 "bounceto|postmaster@%s\n" ,
342 SPOOLMIME, msgnum, time(NULL), config.c_fqdn );
344 /* Generate delivery instructions for each recipient */
345 for (nptr = sc->listrecps; nptr != NULL; nptr = nptr->next) {
346 sprintf(&instr[strlen(instr)], "remote|%s|0||\n",
351 * Generate a message from the instructions
353 imsg = mallok(sizeof(struct CtdlMessage));
354 memset(imsg, 0, sizeof(struct CtdlMessage));
355 imsg->cm_magic = CTDLMESSAGE_MAGIC;
356 imsg->cm_anon_type = MES_NORMAL;
357 imsg->cm_format_type = FMT_RFC822;
358 imsg->cm_fields['A'] = strdoop("Citadel");
359 imsg->cm_fields['M'] = instr;
361 /* Save delivery instructions in spoolout room */
362 CtdlSaveMsg(imsg, "", SMTP_SPOOLOUT_ROOM, MES_LOCAL);
363 CtdlFreeMessage(imsg);
367 * Process IGnet push shares
369 if (sc->ignet_push_shares != NULL) {
371 msg = CtdlFetchMessage(msgnum);
374 /* Prepend our node name to the Path field whenever
375 * sending a message to another IGnet node
377 if (msg->cm_fields['P'] == NULL) {
378 msg->cm_fields['P'] = strdoop("username");
380 newpath = mallok(strlen(msg->cm_fields['P']) +
381 strlen(config.c_nodename) + 2);
382 sprintf(newpath, "%s!%s", config.c_nodename,
383 msg->cm_fields['P']);
384 phree(msg->cm_fields['P']);
385 msg->cm_fields['P'] = newpath;
388 * Force the message to appear in the correct room
389 * on the far end by setting the C field correctly
391 if (msg->cm_fields['C'] != NULL) {
392 phree(msg->cm_fields['C']);
394 msg->cm_fields['C'] = strdoop(CC->quickroom.QRname);
397 * Determine if this message is set to be deleted
398 * after sending out on the network
400 if (msg->cm_fields['S'] != NULL) {
401 if (!strcasecmp(msg->cm_fields['S'],
403 delete_after_send = 1;
408 * Now serialize it for transmission
410 serialize_message(&sermsg, msg);
412 /* Now send it to every node */
413 for (nptr = sc->ignet_push_shares; nptr != NULL;
418 /* Check for valid node name */
419 if (is_valid_node(NULL,NULL,nptr->name) != 0) {
420 lprintf(3, "Invalid node <%s>\n",
425 /* Check for split horizon */
426 lprintf(9, "Path is %s\n", msg->cm_fields['P']);
427 bang = num_tokens(msg->cm_fields['P'], '!');
428 if (bang > 1) for (i=0; i<(bang-1); ++i) {
429 extract_token(buf, msg->cm_fields['P'],
431 if (!strcasecmp(buf, nptr->name)) {
436 /* Send the message */
439 "./network/spoolout/%s",
441 fp = fopen(filename, "ab");
450 CtdlFreeMessage(msg);
454 /* update lastsent */
455 sc->lastsent = msgnum;
457 /* Delete this message if delete-after-send is set */
458 if (delete_after_send) {
459 CtdlDeleteMessages(CC->quickroom.QRname, msgnum, "");
468 * Batch up and send all outbound traffic from the current room
470 void network_spoolout_room(char *room_to_spool) {
475 struct SpoolControl sc;
476 /* struct namelist *digestrecps = NULL; */
477 struct namelist *nptr;
479 lprintf(7, "Spooling <%s>\n", room_to_spool);
480 if (getroom(&CC->quickroom, room_to_spool) != 0) {
481 lprintf(1, "ERROR: cannot load <%s>\n", room_to_spool);
485 memset(&sc, 0, sizeof(struct SpoolControl));
486 assoc_file_name(filename, &CC->quickroom, "netconfigs");
488 fp = fopen(filename, "r");
490 lprintf(7, "Outbound batch processing skipped for <%s>\n",
491 CC->quickroom.QRname);
495 lprintf(5, "Outbound batch processing started for <%s>\n",
496 CC->quickroom.QRname);
498 while (fgets(buf, sizeof buf, fp) != NULL) {
499 buf[strlen(buf)-1] = 0;
501 extract(instr, buf, 0);
502 if (!strcasecmp(instr, "lastsent")) {
503 sc.lastsent = extract_long(buf, 1);
505 else if (!strcasecmp(instr, "listrecp")) {
506 nptr = (struct namelist *)
507 mallok(sizeof(struct namelist));
508 nptr->next = sc.listrecps;
509 extract(nptr->name, buf, 1);
512 else if (!strcasecmp(instr, "ignet_push_share")) {
513 nptr = (struct namelist *)
514 mallok(sizeof(struct namelist));
515 nptr->next = sc.ignet_push_shares;
516 extract(nptr->name, buf, 1);
517 sc.ignet_push_shares = nptr;
525 /* Do something useful */
526 CtdlForEachMessage(MSGS_GT, sc.lastsent, (-63), NULL, NULL,
527 network_spool_msg, &sc);
530 /* Now rewrite the config file */
531 fp = fopen(filename, "w");
533 lprintf(1, "ERROR: cannot open %s: %s\n",
534 filename, strerror(errno));
537 fprintf(fp, "lastsent|%ld\n", sc.lastsent);
539 /* Write out the listrecps while freeing from memory at the
540 * same time. Am I clever or what? :)
542 while (sc.listrecps != NULL) {
543 fprintf(fp, "listrecp|%s\n", sc.listrecps->name);
544 nptr = sc.listrecps->next;
548 while (sc.ignet_push_shares != NULL) {
549 fprintf(fp, "ignet_push_share|%s\n",
550 sc.ignet_push_shares->name);
551 nptr = sc.ignet_push_shares->next;
552 phree(sc.ignet_push_shares);
553 sc.ignet_push_shares = nptr;
559 lprintf(5, "Outbound batch processing finished for <%s>\n",
560 CC->quickroom.QRname);
565 * Batch up and send all outbound traffic from the current room
567 void network_queue_room(struct quickroom *qrbuf, void *data) {
568 struct RoomProcList *ptr;
570 ptr = (struct RoomProcList *) mallok(sizeof (struct RoomProcList));
571 if (ptr == NULL) return;
573 safestrncpy(ptr->name, qrbuf->QRname, sizeof ptr->name);
580 * Learn topology from path fields
582 void network_learn_topology(char *node, char *path) {
584 struct NetMap *nmptr;
588 if (num_tokens(path, '!') < 3) return;
589 for (nmptr = the_netmap; nmptr != NULL; nmptr = nmptr->next) {
590 if (!strcasecmp(nmptr->nodename, node)) {
591 extract_token(nmptr->nexthop, path, 0, '!');
592 nmptr->lastcontact = time(NULL);
597 /* If we got here then it's not in the map, so add it. */
598 nmptr = (struct NetMap *) mallok(sizeof (struct NetMap));
599 strcpy(nmptr->nodename, node);
600 nmptr->lastcontact = time(NULL);
601 extract_token(nmptr->nexthop, path, 0, '!');
602 nmptr->next = the_netmap;
609 * Process a buffer containing a single message from a single file
610 * from the inbound queue
612 void network_process_buffer(char *buffer, long size) {
613 struct CtdlMessage *msg;
618 struct usersupp tempUS;
620 char target_room[ROOMNAMELEN];
621 struct ser_ret sermsg;
622 char *oldpath = NULL;
626 /* Set default target room to trash */
627 strcpy(target_room, TWITROOM);
629 /* Load the message into memory */
630 msg = (struct CtdlMessage *) mallok(sizeof(struct CtdlMessage));
631 memset(msg, 0, sizeof(struct CtdlMessage));
632 msg->cm_magic = CTDLMESSAGE_MAGIC;
633 msg->cm_anon_type = buffer[1];
634 msg->cm_format_type = buffer[2];
636 for (pos = 3; pos < size; ++pos) {
638 msg->cm_fields[field] = strdoop(&buffer[pos+1]);
639 pos = pos + strlen(&buffer[(int)pos]);
642 /* Check for message routing */
643 if (msg->cm_fields['D'] != NULL) {
644 if (strcasecmp(msg->cm_fields['D'], config.c_nodename)) {
646 /* route the message */
647 if (is_valid_node(NULL, NULL,
648 msg->cm_fields['D']) == 0) {
650 /* prepend our node to the path */
651 if (msg->cm_fields['P'] != NULL) {
652 oldpath = msg->cm_fields['P'];
653 msg->cm_fields['P'] = NULL;
656 oldpath = strdoop("unknown_user");
658 msg->cm_fields['P'] =
659 mallok(strlen(oldpath) + SIZ);
660 sprintf(msg->cm_fields['P'], "%s!%s",
661 config.c_nodename, oldpath);
664 /* serialize the message */
665 serialize_message(&sermsg, msg);
669 "./network/spoolout/%s",
670 msg->cm_fields['D']);
671 fp = fopen(filename, "ab");
678 CtdlFreeMessage(msg);
682 else { /* invalid destination node name */
684 /* FIXME bounce the msg */
690 /* FIXME check to see if we already have this message */
692 /* Learn network topology from the path */
693 if ((msg->cm_fields['N'] != NULL) && (msg->cm_fields['P'] != NULL)) {
694 network_learn_topology(msg->cm_fields['N'],
695 msg->cm_fields['P']);
698 /* Does it have a recipient? If so, validate it... */
699 if (msg->cm_fields['R'] != NULL) {
701 safestrncpy(recp, msg->cm_fields['R'], sizeof(recp));
703 e = alias(recp); /* alias and mail type */
704 if ((recp[0] == 0) || (e == MES_ERROR)) {
706 /* FIXME bounce the msg */
709 else if (e == MES_LOCAL) {
710 a = getuser(&tempUS, recp);
712 /* FIXME bounce the msg */
715 MailboxName(target_room, &tempUS, MAILROOM);
720 else if (msg->cm_fields['C'] != NULL) {
721 safestrncpy(target_room,
726 else if (msg->cm_fields['O'] != NULL) {
727 safestrncpy(target_room,
732 /* save the message into a room */
733 msg->cm_flags = CM_SKIP_HOOKS;
734 CtdlSaveMsg(msg, "", target_room, 0);
735 CtdlFreeMessage(msg);
740 * Process a single message from a single file from the inbound queue
742 void network_process_message(FILE *fp, long msgstart, long msgend) {
747 hold_pos = ftell(fp);
748 size = msgend - msgstart + 1;
749 buffer = mallok(size);
750 if (buffer != NULL) {
751 fseek(fp, msgstart, SEEK_SET);
752 fread(buffer, size, 1, fp);
753 network_process_buffer(buffer, size);
757 fseek(fp, hold_pos, SEEK_SET);
762 * Process a single file from the inbound queue
764 void network_process_file(char *filename) {
766 long msgstart = (-1L);
771 lprintf(7, "network: processing <%s>\n", filename);
773 fp = fopen(filename, "rb");
775 lprintf(5, "Error opening %s: %s\n",
776 filename, strerror(errno));
780 /* Look for messages in the data stream and break them out */
781 while (ch = getc(fp), ch >= 0) {
784 if (msgstart >= 0L) {
786 network_process_message(fp, msgstart, msgend);
795 if (msgstart >= 0L) {
796 network_process_message(fp, msgstart, msgend);
805 * Process anything in the inbound queue
807 void network_do_spoolin(void) {
812 dp = opendir("./network/spoolin");
813 if (dp == NULL) return;
815 while (d = readdir(dp), d != NULL) {
816 sprintf(filename, "./network/spoolin/%s", d->d_name);
817 network_process_file(filename);
829 * receive network spool from the remote system
831 void receive_spool(int sock, char *remote_nodename) {
835 static char pbuf[IGNET_PACKET_SIZE];
836 char tempfilename[PATH_MAX];
840 strcpy(tempfilename, tmpnam(NULL));
841 if (sock_puts(sock, "NDOP") < 0) return;
842 if (sock_gets(sock, buf) < 0) return;
843 lprintf(9, "<%s\n", buf);
847 download_len = extract_long(&buf[4], 0);
850 fp = fopen(tempfilename, "w");
852 lprintf(9, "cannot open download file locally: %s\n",
857 while (bytes_received < download_len) {
858 sprintf(buf, "READ %ld|%ld",
860 ((download_len - bytes_received > IGNET_PACKET_SIZE)
861 ? IGNET_PACKET_SIZE : (download_len - bytes_received)));
862 if (sock_puts(sock, buf) < 0) {
864 unlink(tempfilename);
867 if (sock_gets(sock, buf) < 0) {
869 unlink(tempfilename);
873 plen = extract_long(&buf[4], 0);
874 if (sock_read(sock, pbuf, plen) < 0) {
876 unlink(tempfilename);
879 fwrite((char *) pbuf, plen, 1, fp);
880 bytes_received = bytes_received + plen;
885 if (sock_puts(sock, "CLOS") < 0) {
886 unlink(tempfilename);
889 if (sock_gets(sock, buf) < 0) {
890 unlink(tempfilename);
893 lprintf(9, "%s\n", buf);
894 sprintf(buf, "mv %s ./network/spoolin/%s.%ld",
895 tempfilename, remote_nodename, (long) getpid());
902 * transmit network spool to the remote system
904 void transmit_spool(int sock, char *remote_nodename)
909 long bytes_to_write, thisblock;
913 if (sock_puts(sock, "NUOP") < 0) return;
914 if (sock_gets(sock, buf) < 0) return;
915 lprintf(9, "<%s\n", buf);
920 sprintf(sfname, "./network/spoolout/%s", remote_nodename);
921 fd = open(sfname, O_RDONLY);
923 if (errno == ENOENT) {
924 lprintf(9, "Nothing to send.\n");
926 lprintf(5, "cannot open upload file locally: %s\n",
931 while (plen = (long) read(fd, pbuf, IGNET_PACKET_SIZE), plen > 0L) {
932 bytes_to_write = plen;
933 while (bytes_to_write > 0L) {
934 sprintf(buf, "WRIT %ld", bytes_to_write);
935 if (sock_puts(sock, buf) < 0) {
939 if (sock_gets(sock, buf) < 0) {
943 thisblock = atol(&buf[4]);
945 if (sock_write(sock, pbuf,
946 (int) thisblock) < 0) {
950 bytes_to_write = bytes_to_write - thisblock;
959 if (sock_puts(sock, "UCLS 1") < 0) return;
960 if (sock_gets(sock, buf) < 0) return;
961 lprintf(9, "<%s\n", buf);
970 * Poll one Citadel node (called by network_poll_other_citadel_nodes() below)
972 void network_poll_node(char *node, char *secret, char *host, char *port) {
976 lprintf(5, "Polling node <%s> at %s:%s\n", node, host, port);
978 sock = sock_connect(host, port, "tcp");
980 lprintf(7, "Could not connect: %s\n", strerror(errno));
984 lprintf(9, "Connected!\n");
986 /* Read the server greeting */
987 if (sock_gets(sock, buf) < 0) goto bail;
988 lprintf(9, ">%s\n", buf);
990 /* Identify ourselves */
991 sprintf(buf, "NETP %s|%s", config.c_nodename, secret);
992 lprintf(9, "<%s\n", buf);
993 if (sock_puts(sock, buf) <0) goto bail;
994 if (sock_gets(sock, buf) < 0) goto bail;
995 lprintf(9, ">%s\n", buf);
996 if (buf[0] != '2') goto bail;
998 /* At this point we are authenticated. */
999 receive_spool(sock, node);
1000 transmit_spool(sock, node);
1002 sock_puts(sock, "QUIT");
1003 bail: sock_close(sock);
1009 * Poll other Citadel nodes and transfer inbound/outbound network data.
1011 void network_poll_other_citadel_nodes(void) {
1012 char *ignetcfg = NULL;
1020 ignetcfg = CtdlGetSysConfig(IGNETCFG);
1021 if (ignetcfg == NULL) return; /* no nodes defined */
1023 /* Use the string tokenizer to grab one line at a time */
1024 for (i=0; i<num_tokens(ignetcfg, '\n'); ++i) {
1025 extract_token(linebuf, ignetcfg, i, '\n');
1026 extract(node, linebuf, 0);
1027 extract(secret, linebuf, 1);
1028 extract(host, linebuf, 2);
1029 extract(port, linebuf, 3);
1030 if ( (strlen(node) > 0) && (strlen(secret) > 0)
1031 && (strlen(host) > 0) && strlen(port) > 0) {
1032 network_poll_node(node, secret, host, port);
1046 * network_do_queue()
1048 * Run through the rooms doing various types of network stuff.
1050 void network_do_queue(void) {
1051 static int doing_queue = 0;
1052 static time_t last_run = 0L;
1053 struct RoomProcList *ptr;
1056 * Run no more frequently than once every n seconds
1058 if ( (time(NULL) - last_run) < NETWORK_QUEUE_FREQUENCY ) return;
1061 * This is a simple concurrency check to make sure only one queue run
1062 * is done at a time. We could do this with a mutex, but since we
1063 * don't really require extremely fine granularity here, we'll do it
1064 * with a static variable instead.
1066 if (doing_queue) return;
1068 last_run = time(NULL);
1071 * Poll other Citadel nodes.
1073 network_poll_other_citadel_nodes();
1076 * Load the network map into memory.
1081 * Go ahead and run the queue
1083 lprintf(7, "network: loading outbound queue\n");
1084 ForEachRoom(network_queue_room, NULL);
1086 lprintf(7, "network: running outbound queue\n");
1087 while (rplist != NULL) {
1088 network_spoolout_room(rplist->name);
1090 rplist = rplist->next;
1094 lprintf(7, "network: processing inbound queue\n");
1095 network_do_spoolin();
1097 write_network_map();
1099 lprintf(7, "network: queue run completed\n");
1106 * cmd_netp() - authenticate to the server as another Citadel node polling
1107 * for network traffic
1109 void cmd_netp(char *cmdbuf)
1117 extract(node, cmdbuf, 0);
1118 extract(pass, cmdbuf, 1);
1120 if (is_valid_node(nexthop, secret, node) != 0) {
1121 cprintf("%d authentication failed\n", ERROR);
1125 if (strcasecmp(pass, secret)) {
1126 cprintf("%d authentication failed\n", ERROR);
1130 safestrncpy(CC->net_node, node, sizeof CC->net_node);
1131 cprintf("%d authenticated as network node '%s'\n", OK,
1138 * Module entry point
1140 char *Dynamic_Module_Init(void)
1142 CtdlRegisterProtoHook(cmd_gnet, "GNET", "Get network config");
1143 CtdlRegisterProtoHook(cmd_snet, "SNET", "Get network config");
1144 CtdlRegisterProtoHook(cmd_netp, "NETP", "Identify as network poller");
1145 CtdlRegisterSessionHook(network_do_queue, EVT_TIMER);