|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T s
Length: 6198 (0x1836)
Types: TextFile
Names: »submit_mgt.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z«
└─⟦e5a54fb17⟧
└─⟦this⟧ »pp-5.0/Src/submit/submit_mgt.c«
/* submit_mgt.c: management stuff */
# ifndef lint
static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Src/submit/RCS/submit_mgt.c,v 5.0 90/09/20 16:23:19 pp Exp Locker: pp $";
# endif
/*
* $Header: /cs/research/pp/hubris/pp-beta/Src/submit/RCS/submit_mgt.c,v 5.0 90/09/20 16:23:19 pp Exp Locker: pp $
*
* $Log: submit_mgt.c,v $
* Revision 5.0 90/09/20 16:23:19 pp
* rcsforce : 5.0 public release
*
*/
#include "head.h"
#include "prm.h"
#include "q.h"
#include "dr.h"
#include <sys/time.h>
/* -- defines -- */
#define MAX_TRACE_HOPS 25
#define MAX_NUM_LOCAL_MTA 5
/* -- externals -- */
extern time_t time();
extern Q_struct Qstruct;
extern int privileged;
extern int return_interval_norm,
return_interval_low,
return_interval_high;
extern int accept_all;
extern int notrace;
extern char *loc_dom_site, *loc_dom_mta,
*ia5_bp, *hdr_822_bp,
io_fpart[];
/* -- globals -- */
CHAN *ch_inbound;
char *mgt_inhost;
int mgt_adtype = AD_822_TYPE;
void message_failure();
/* -- local routines -- */
int cntrl_mgt();
int q_mgt();
void message_failure();
void msg_mgt();
void time_mgt();
void txt_mgt();
static void tracecheck_mgt();
/* --------------------- Begin Routines -------------------------------- */
int cntrl_mgt (prm, qp)
register struct prm_vars *prm;
register Q_struct *qp;
{
CHAN *ch = NULLCHAN;
PP_TRACE (("submit/cntrl_mgt (type = %d)", mgt_adtype));
accept_all = (prm -> prm_opts & PRM_ACCEPTALL) == PRM_ACCEPTALL;
notrace = (prm -> prm_opts & PRM_NOTRACE) == PRM_NOTRACE;
/* -- what incomming channel is calling submit -- */
if (qp -> inbound == NULL ||
(ch_inbound = ch = qp -> inbound -> li_chan) == NULLCHAN)
err_abrt (RP_MECH, "No channel given");
if (ch -> ch_access == CH_MTA) {
if (!privileged)
err_abrt (RP_USER, "Privileged channel");
}
if (ch_inbound -> ch_domain_norm == CH_DOMAIN_NORM_ALL)
ap_norm_all_domains();
else
ap_norm_first_domain();
if ((mgt_inhost = qp -> inbound -> li_mta) == NULLCP) {
if (ch -> ch_chan_type != CH_IN)
err_abrt (RP_USER, "Incomming chan required");
mgt_inhost = loc_dom_site;
} else {
char official[LINESIZE], *subdom;
/* normalise inbound mta */
if (tb_getdomain (mgt_inhost, NULLCP, official,
ch_inbound -> ch_ad_order,
&subdom) == OK
&& official[0]) {
free(qp->inbound->li_mta);
mgt_inhost = qp->inbound->li_mta = strdup(official);
}
if (subdom != NULLCP) free (subdom);
}
mgt_adtype = ch -> ch_ad_type;
if (mgt_adtype == AD_822_TYPE)
qp -> content_return_request = TRUE;
PP_TRACE (("submit/cntrl_mgt (type='%d', order='%d')",
mgt_adtype, ch_inbound -> ch_ad_order));
return (RP_OK);
}
int q_mgt (qp)
register Q_struct *qp;
{
PP_TRACE (("submit/q_mgt (qp)"));
/* -- generate a submit-event-id -- */
if (mgt_adtype == AD_822_TYPE || qp -> msgid.mpduid_string == NULLCP)
MPDUid_new (&qp -> msgid);
/* -- add trace info -- */
trace_add (&qp -> trace, trace_new());
if (qp -> retinterval == 0) {
switch (qp -> priority) {
case PRIO_URGENT:
qp -> retinterval = return_interval_high;
break;
case PRIO_NONURGENT:
qp -> retinterval = return_interval_low;
break;
default:
qp -> retinterval = return_interval_norm;
break;
}
}
return (RP_OK);
}
void time_mgt()
{
time_t then, now;
char buf[BUFSIZ];
if (Qstruct.latest_time != NULLUTC) {
then = utc2time_t(Qstruct.latest_time);
(void) time(&now);
if (then < now) {
(void) sprintf (buf, "This message's latest time has been exceeded");
message_failure (DRR_UNABLE_TO_TRANSFER,
DRD_MAX_TIME_EXPIRED,
buf);
}
}
}
void msg_mgt()
{
PP_TRACE (("submit/msg_mgt()"));
ch_inbound = NULLCHAN;
mgt_inhost = NULLCP;
}
void txt_mgt() /* -- management tasks on the input text -- */
{
PP_TRACE (("submit/txt_mgt()"));
if (isnull (*io_fpart))
err_abrt (RP_MECH, "Help - lost io_part");
/* -- if its an 822 body, check it's parts -- */
if (Qstruct.msgtype == MT_UMPDU &&
list_bpt_find (Qstruct.encodedinfo.eit_types, hdr_822_bp) != NULLIST_BPT)
rd_rfchdr (io_fpart);
if (Qstruct.encodedinfo.eit_types == NULLIST_BPT)
Qstruct.encodedinfo.eit_types = list_bpt_dup (Qstruct.orig_encodedinfo.eit_types);
/* -- check for trace looping -- */
tracecheck_mgt(&Qstruct);
/* -- currently ok -- */
pro_reply (RP_OK, "text input successful");
}
void message_failure (reason, diag, str)
int reason, diag;
char *str;
{
ADDR *ap, *apf = NULLADDR;
extern ADDR *ad_recip;
for (ap = ad_recip; ap; ap = ap -> ad_next) {
if (ap -> ad_resp == FALSE)
continue;
if (ap -> ad_status != AD_STAT_PEND)
continue;
if (apf == NULLADDR)
apf = ap;
ap -> ad_status = AD_STAT_DRREQUIRED;
}
if (apf) {
apf -> ad_reason = reason;
apf -> ad_diagnostic = diag;
apf -> ad_add_info = strdup (str);
}
}
/* --------------------- Static Routines ------------------------------- */
static void tracecheck_mgt (qp)
Q_struct *qp;
{
register Trace *tp;
int nhops = 0, first = 0;
char buf[BUFSIZ];
PP_TRACE (("submit/tracecheck_mgt (qp)"));
for (tp = qp -> trace; tp != NULL; tp = tp -> trace_next) {
/* -- too many hops -- */
if (++nhops > MAX_TRACE_HOPS) {
(void) sprintf (buf,
"%s%s %d",
"This Message has travelled a long time, ",
"there are too many Trace hops", nhops);
message_failure (DRR_UNABLE_TO_TRANSFER,
DRD_LOOP_DETECTED, buf);
PP_LOG(LLOG_EXCEPTIONS,
("%s", buf));
return;
}
if (tp -> trace_mta != NULLCP) {
/* can only check against those with mta specified */
if (lexequ(tp -> trace_mta, loc_dom_mta) == 0) {
if (first >= MAX_NUM_LOCAL_MTA) {
(void) sprintf (buf, "%s%s",
"A loop has been detected in the Trace at ",
"field for this Message");
PP_LOG(LLOG_EXCEPTIONS,
("tracecheck_mgt(%s)", buf));
message_failure (DRR_UNABLE_TO_TRANSFER,
DRD_LOOP_DETECTED, buf);
return;
} else
first++;
}
}
}
}