Back to index

citadel  8.12
Classes | Defines | Typedefs | Enumerations | Functions | Variables
serv_network.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  namelist

Defines

#define DBGLOG(LEVEL)   if ((LEVEL != LOG_DEBUG) || (NetQDebugEnabled != 0))
#define QN_syslog(LEVEL, FORMAT,...)
#define QNM_syslog(LEVEL, FORMAT)

Typedefs

typedef struct namelist

Enumerations

enum  { NTT_ADD, NTT_REMOVE, NTT_CHECK }

Functions

void free_netfilter_list (void)
void load_network_filter_list (void)
void network_queue_room (struct ctdlroom *, void *)
void network_bounce (struct CtdlMessage *msg, char *reason)
int network_usetable (struct CtdlMessage *msg)
int network_talking_to (const char *nodename, long len, int operation)

Variables

int NetQDebugEnabled

Class Documentation

struct namelist

Definition at line 35 of file serv_network.h.

Collaboration diagram for namelist:
Class Members
char name
namelist * next

Define Documentation

#define DBGLOG (   LEVEL)    if ((LEVEL != LOG_DEBUG) || (NetQDebugEnabled != 0))

Definition at line 21 of file serv_network.h.

#define QN_syslog (   LEVEL,
  FORMAT,
  ... 
)
Value:
DBGLOG(LEVEL) syslog(LEVEL,                      \
                          "CC[%d]" FORMAT, \
                          CCC->cs_pid, __VA_ARGS__)

Definition at line 23 of file serv_network.h.

#define QNM_syslog (   LEVEL,
  FORMAT 
)
Value:
DBGLOG(LEVEL) syslog(LEVEL,                      \
                          "CC[%d]" FORMAT, \
                          CCC->cs_pid)

Definition at line 28 of file serv_network.h.


Typedef Documentation

typedef struct namelist

Definition at line 33 of file serv_network.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
NTT_ADD 
NTT_REMOVE 
NTT_CHECK 

Definition at line 56 of file serv_network.h.


Function Documentation

void free_netfilter_list ( void  )

Definition at line 119 of file serv_netfilter.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void load_network_filter_list ( void  )

Definition at line 125 of file serv_netfilter.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void network_bounce ( struct CtdlMessage msg,
char *  reason 
)

Definition at line 399 of file serv_network.c.

{
       struct CitContext *CCC = CC;
       char *oldpath = NULL;
       char buf[SIZ];
       char bouncesource[SIZ];
       char recipient[SIZ];
       struct recptypes *valid = NULL;
       char force_room[ROOMNAMELEN];
       static int serialnum = 0;
       size_t size;

       QNM_syslog(LOG_DEBUG, "entering network_bounce()\n");

       if (msg == NULL) return;

       snprintf(bouncesource, sizeof bouncesource, "%s@%s", BOUNCESOURCE, config.c_nodename);

       /* 
        * Give it a fresh message ID
        */
       if (msg->cm_fields['I'] != NULL) {
              free(msg->cm_fields['I']);
       }
       snprintf(buf, sizeof buf, "%ld.%04lx.%04x@%s",
              (long)time(NULL), (long)getpid(), ++serialnum, config.c_fqdn);
       msg->cm_fields['I'] = strdup(buf);

       /*
        * FIXME ... right now we're just sending a bounce; we really want to
        * include the text of the bounced message.
        */
       if (msg->cm_fields['M'] != NULL) {
              free(msg->cm_fields['M']);
       }
       msg->cm_fields['M'] = strdup(reason);
       msg->cm_format_type = 0;

       /*
        * Turn the message around
        */
       if (msg->cm_fields['R'] == NULL) {
              free(msg->cm_fields['R']);
       }

       if (msg->cm_fields['D'] == NULL) {
              free(msg->cm_fields['D']);
       }

       snprintf(recipient, sizeof recipient, "%s@%s",
              msg->cm_fields['A'], msg->cm_fields['N']);

       if (msg->cm_fields['A'] == NULL) {
              free(msg->cm_fields['A']);
       }

       if (msg->cm_fields['N'] == NULL) {
              free(msg->cm_fields['N']);
       }

       if (msg->cm_fields['U'] == NULL) {
              free(msg->cm_fields['U']);
       }

       msg->cm_fields['A'] = strdup(BOUNCESOURCE);
       msg->cm_fields['N'] = strdup(config.c_nodename);
       msg->cm_fields['U'] = strdup("Delivery Status Notification (Failure)");

       /* prepend our node to the path */
       if (msg->cm_fields['P'] != NULL) {
              oldpath = msg->cm_fields['P'];
              msg->cm_fields['P'] = NULL;
       }
       else {
              oldpath = strdup("unknown_user");
       }
       size = strlen(oldpath) + SIZ;
       msg->cm_fields['P'] = malloc(size);
       snprintf(msg->cm_fields['P'], size, "%s!%s", config.c_nodename, oldpath);
       free(oldpath);

       /* Now submit the message */
       valid = validate_recipients(recipient, NULL, 0);
       if (valid != NULL) if (valid->num_error != 0) {
              free_recipients(valid);
              valid = NULL;
       }
       if ( (valid == NULL) || (!strcasecmp(recipient, bouncesource)) ) {
              strcpy(force_room, config.c_aideroom);
       }
       else {
              strcpy(force_room, "");
       }
       if ( (valid == NULL) && IsEmptyStr(force_room) ) {
              strcpy(force_room, config.c_aideroom);
       }
       CtdlSubmitMsg(msg, valid, force_room, 0);

       /* Clean up */
       if (valid != NULL) free_recipients(valid);
       CtdlFreeMessage(msg);
       QNM_syslog(LOG_DEBUG, "leaving network_bounce()\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void network_queue_room ( struct ctdlroom ,
void *   
)

Definition at line 344 of file serv_network.c.

                                                            {
       int i;
       struct RoomProcList *ptr;

       if (qrbuf->QRdefaultview == VIEW_QUEUE)
              return;
       ptr = (struct RoomProcList *) malloc(sizeof (struct RoomProcList));
       if (ptr == NULL) return;

       ptr->namelen = strlen(qrbuf->QRname);
       if (ptr->namelen > ROOMNAMELEN)
              ptr->namelen = ROOMNAMELEN - 1;

       memcpy (ptr->name, qrbuf->QRname, ptr->namelen);
       ptr->name[ptr->namelen] = '\0';
       ptr->QRNum = qrbuf->QRnumber;

       for (i = 0; i < ptr->namelen; i++)
       {
              ptr->lcname[i] = tolower(ptr->name[i]);
       }
       ptr->lcname[ptr->namelen] = '\0';
       ptr->key = hashlittle(ptr->lcname, ptr->namelen, 9872345);

       begin_critical_section(S_RPLIST);
       ptr->next = rplist;
       rplist = ptr;
       end_critical_section(S_RPLIST);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int network_talking_to ( const char *  nodename,
long  len,
int  operation 
)

Definition at line 659 of file serv_network.c.

                                                                      {

       int retval = 0;
       HashPos *Pos = NULL;
       void *vdata;

       begin_critical_section(S_NTTLIST);

       switch(operation) {

              case NTT_ADD:
                     if (nttlist == NULL) 
                            nttlist = NewHash(1, NULL);
                     Put(nttlist, nodename, len, NewStrBufPlain(nodename, len), HFreeStrBuf);
                     if (NTTDebugEnabled) syslog(LOG_DEBUG, "nttlist: added <%s>\n", nodename);
                     break;
              case NTT_REMOVE:
                     if ((nttlist == NULL) ||
                         (GetCount(nttlist) == 0))
                            break;
                     Pos = GetNewHashPos(nttlist, 1);
                     if (GetHashPosFromKey (nttlist, nodename, len, Pos))
                            DeleteEntryFromHash(nttlist, Pos);
                     DeleteHashPos(&Pos);
                     if (NTTDebugEnabled) syslog(LOG_DEBUG, "nttlist: removed <%s>\n", nodename);

                     break;

              case NTT_CHECK:
                     if ((nttlist == NULL) ||
                         (GetCount(nttlist) == 0))
                            break;
                     if (GetHash(nttlist, nodename, len, &vdata))
                            retval ++;
                     if (NTTDebugEnabled) syslog(LOG_DEBUG, "nttlist: have [%d] <%s>\n", retval, nodename);
                     break;
       }

       end_critical_section(S_NTTLIST);
       return(retval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int network_usetable ( struct CtdlMessage msg)

Definition at line 153 of file serv_network.c.

{
       struct CitContext *CCC = CC;
       char msgid[SIZ];
       struct cdbdata *cdbut;
       struct UseTable ut;

       /* Bail out if we can't generate a message ID */
       if (msg == NULL) {
              return(0);
       }
       if (msg->cm_fields['I'] == NULL) {
              return(0);
       }
       if (IsEmptyStr(msg->cm_fields['I'])) {
              return(0);
       }

       /* Generate the message ID */
       strcpy(msgid, msg->cm_fields['I']);
       if (haschar(msgid, '@') == 0) {
              strcat(msgid, "@");
              if (msg->cm_fields['N'] != NULL) {
                     strcat(msgid, msg->cm_fields['N']);
              }
              else {
                     return(0);
              }
       }

       cdbut = cdb_fetch(CDB_USETABLE, msgid, strlen(msgid));
       if (cdbut != NULL) {
              cdb_free(cdbut);
              QN_syslog(LOG_DEBUG, "network_usetable() : we already have %s\n", msgid);
              return(1);
       }

       /* If we got to this point, it's unique: add it. */
       strcpy(ut.ut_msgid, msgid);
       ut.ut_timestamp = time(NULL);
       cdb_store(CDB_USETABLE, msgid, strlen(msgid), &ut, sizeof(struct UseTable) );
       return(0);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 95 of file serv_network.c.