-void cmd_netp(char *cmdbuf)
-{
- struct CitContext *CCC = CC;
- HashList *working_ignetcfg;
- char *node;
- StrBuf *NodeStr;
- long nodelen;
- int v;
- long lens[2];
- const char *strs[2];
-
- const StrBuf *secret = NULL;
- const StrBuf *nexthop = NULL;
- char err_buf[SIZ] = "";
-
- /* Authenticate */
- node = CCC->curr_user;
- nodelen = extract_token(CCC->curr_user, cmdbuf, 0, '|', sizeof CCC->curr_user);
- NodeStr = NewStrBufPlain(node, nodelen);
- /* load the IGnet Configuration to check node validity */
- working_ignetcfg = CtdlLoadIgNetCfg();
- v = CtdlIsValidNode(&nexthop, &secret, NodeStr, working_ignetcfg, NULL);
- if (v != 0) {
- snprintf(err_buf, sizeof err_buf,
- "An unknown Citadel server called \"%s\" attempted to connect from %s [%s].\n",
- node, CCC->cs_host, CCC->cs_addr
- );
- syslog(LOG_WARNING, "%s", err_buf);
- cprintf("%d authentication failed\n", ERROR + PASSWORD_REQUIRED);
-
- strs[0] = CCC->cs_addr;
- lens[0] = strlen(CCC->cs_addr);
-
- strs[1] = "SRV_UNKNOWN";
- lens[1] = sizeof("SRV_UNKNOWN" - 1);
-
- CtdlAideFPMessage(
- err_buf,
- "IGNet Networking.",
- 2, strs, (long*) &lens);
-
- DeleteHash(&working_ignetcfg);
- FreeStrBuf(&NodeStr);
- return;
- }
-
- extract_token(CCC->user.password, cmdbuf, 1, '|', sizeof CCC->user.password);
- if (strcasecmp(CCC->user.password, ChrPtr(secret))) {
- snprintf(err_buf, sizeof err_buf,
- "A Citadel server at %s [%s] failed to authenticate as network node \"%s\".\n",
- CCC->cs_host, CCC->cs_addr, node
- );
- syslog(LOG_WARNING, "%s", err_buf);
- cprintf("%d authentication failed\n", ERROR + PASSWORD_REQUIRED);
-
- strs[0] = CCC->cs_addr;
- lens[0] = strlen(CCC->cs_addr);
-
- strs[1] = "SRV_PW";
- lens[1] = sizeof("SRV_PW" - 1);
-
- CtdlAideFPMessage(
- err_buf,
- "IGNet Networking.",
- 2, strs, (long*) &lens);
-
- DeleteHash(&working_ignetcfg);
- FreeStrBuf(&NodeStr);
- return;
- }
-
- if (CtdlNetworkTalkingTo(node, nodelen, NTT_CHECK)) {
- syslog(LOG_WARNING, "Duplicate session for network node <%s>", node);
- cprintf("%d Already talking to %s right now\n", ERROR + RESOURCE_BUSY, node);
- DeleteHash(&working_ignetcfg);
- FreeStrBuf(&NodeStr);
- return;
- }
- nodelen = safestrncpy(CCC->net_node, node, sizeof CCC->net_node);
- CtdlNetworkTalkingTo(CCC->net_node, nodelen, NTT_ADD);
- syslog(LOG_NOTICE, "Network node <%s> logged in from %s [%s]\n",
- CCC->net_node, CCC->cs_host, CCC->cs_addr
- );
- cprintf("%d authenticated as network node '%s'\n", CIT_OK, CCC->net_node);
- DeleteHash(&working_ignetcfg);
- FreeStrBuf(&NodeStr);
-}
-
-
-/*-----------------------------------------------------------------------------*
- * Network maps: evaluate other nodes *
- *-----------------------------------------------------------------------------*/
-
-void DeleteNetMap(void *vNetMap)
-{
- CtdlNetMap *TheNetMap = (CtdlNetMap*) vNetMap;
- FreeStrBuf(&TheNetMap->NodeName);
- FreeStrBuf(&TheNetMap->NextHop);
- free(TheNetMap);
-}
-
-CtdlNetMap *NewNetMap(StrBuf *SerializedNetMap)