25 static int send_report (
28 static int add_recips_positive(
29 struct X400mtMessage *mp
31 static int add_recips_negative(
32 struct X400mtMessage *mp
35 struct X400mtMessage *mp
37 static int add_env_recip_info(
38 struct X400Recipient *rp
40 static void usage(
void);
44 static int do_redi_hist(
45 struct X400Recipient *rp
48 static int do_redi_hist_env(
49 struct X400mtMessage *msg
52 static void do_origandl(
53 struct X400mtMessage *msg
62 #define HOSTNAME "dhcp-164" 64 static char *optstr =
"uo:O:r:g:G:c:l:R:y:C:iaqsAv";
67 static const char orig_s[] =
"/S=x400test-orig/OU="HOSTNAME
"/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
68 static const char *orig = orig_s;
71 static const char recip_s[] =
"/S=x400test-recip2/OU="HOSTNAME
"/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
72 static const char *recip = recip_s;
76 static int def_content_type = 2;
77 static int def_bool = 0;
78 static int def_priority = 2;
81 static const char def_utc[] =
"080924120000";
82 static const char msg_id[] =
"/PRMD=TestPRMD/ADMD=TestADMD/C=GB/;"HOSTNAME
".2810401-030924.140212";
83 static const char content_id[] =
"030924.140212";
84 static const char content_corr[] =
"CONTENT-CORROLATOR";
85 static const char latest_del_time[] =
"120927120000Z";
88 static const int importance = 2;
89 static const int sensitivity = 3;
90 static const int autoforwarded = 1;
93 static const char text[] =
"First line\r\nSecond line\r\n";
94 static const char ipm_id[] =
"1064400656.24922*";
95 static const char ipm_rep_id[] =
"1064400656.24923*";
96 static const char ipm_obs_id[] =
"1064400656.24924*";
97 static const char ipm_rel_id[] =
"1064400656.24925*";
98 static const char orig_ref[] =
"orig-ref-val";
110 orig = strdup(x400_default_gw_originator);
111 recip = strdup(x400_default_gw_recipient);
113 if (get_args(argc, argv, optstr)) {
118 if (x400_channel == NULL) {
119 printf(
"You must specify an X.400 channel\n");
124 printf(
"Delivery Report type (0 = Positive, 1 = Negative): ");
125 drtype = ic_fgetc(x400_contype, stdin);
126 if ((drtype !=
'0') && (drtype !=
'1'))
131 return send_report(drtype);
134 static int send_report (
139 struct X400mtSession *sp;
140 struct X400mtMessage *mp;
142 if (x400_channel == NULL) {
143 fprintf (stderr,
"No x400_channel value set in x400tailor file");
150 fprintf (stderr,
"Error in Open: %s\n",
X400mtError (status));
165 status = add_recips_positive(mp);
167 status = add_recips_negative(mp);
170 #define ADD_TRACE_INFO 1 171 #ifdef ADD_TRACE_INFO 173 struct X400TraceInfo *info1;
177 fprintf(stderr,
"Failed to allocate new trace info object \n");
184 "/PRMD=wibble/ADMD=TestADMD/C=GB/",
188 "Failed to add X400_S_GLOBAL_DOMAIN_ID to trace info\n");
198 "Failed to add X400_S_DSI_ARRIVAL_TIME to trace info\n");
205 "/PRMD=atmpdom/ADMD=TestADMD/C=GB/",
209 "Failed to add X400_S_DSI_ATTEMPTED_DOMAIN to trace info\n");
221 "Failed to add X400_S_DSI_AA_DEF_TIME to trace info\n");
228 status = build_env(mp);
235 fprintf (stderr,
"Error in MsgSend: %s\n",
X400mtError (status));
249 static int add_recips_positive(
250 struct X400mtMessage *mp
253 struct X400Recipient *rp;
263 status = add_env_recip_info (rp);
273 status = add_env_recip_info (rp);
279 fprintf (stderr,
"X400mtMsgAddStrParam returned error: %s\n",
X400mtError (status));
286 fprintf (stderr,
"X400mtMsgAddStrParam returned error: %s\n",
X400mtError (status));
293 fprintf (stderr,
"X400mtMsgAddStrParam returned error: %s\n",
X400mtError (status));
296 #define USE_REDIRECTION_HISTORY 1 297 #ifdef USE_REDIRECTION_HISTORY 308 static int add_recips_negative(
309 struct X400mtMessage *mp
312 struct X400Recipient *rp;
322 status = add_env_recip_info (rp);
332 status = add_env_recip_info (rp);
338 fprintf (stderr,
"X400mtMsgAddStrParam returned error: %s\n",
X400mtError (status));
345 fprintf (stderr,
"X400mtMsgAddStrParam returned error: %s\n",
X400mtError (status));
352 fprintf (stderr,
"X400mtMsgAddIntParam returned error: %s\n",
X400mtError (status));
359 fprintf (stderr,
"X400mtMsgAddIntParam returned error: %s\n",
X400mtError (status));
366 static int build_env(
367 struct X400mtMessage *mp
443 #ifdef USE_REDIRECTION_HISTORY 445 do_redi_hist_env(mp);
455 static int add_env_recip_info(
456 struct X400Recipient *rp
479 static void usage(
void) {
480 printf(
"usage: %s\n", optstr);
481 printf(
"\t where:\n");
482 printf(
"\t -u : Don't prompt to override defaults \n");
483 printf(
"\t -o : Originator \n");
484 printf(
"\t -O : Originator Return Address \n");
485 printf(
"\t -r : Recipient\n");
486 printf(
"\t -c : X.400 passive channel\n");
487 printf(
"\t -l : Logline\n");
488 printf(
"\t -R : Reports (0 - never, 1 - always, 2 - always NDR \n");
489 printf(
"\t -y : Priority (0 - normal, 1 - non-urgent, 2 - urgent \n");
490 printf(
"\t -C : Content Type (2/22/772/OID) \n");
491 printf(
"\t -i : Implicit conversion prohibited = TRUE \n");
492 printf(
"\t -a : Alternate Recipient Prohibited = TRUE \n");
493 printf(
"\t -q : Content Return Request = TRUE \n");
494 printf(
"\t -s : Disclosure of Recipient = FALSE \n");
495 printf(
"\t -A : Recipient Reassignment Prohibited = FALSE \n");
496 printf(
"\t -v : Conversion with Loss Prohibited = FALSE \n");
501 static int do_redi_hist(
502 struct X400Recipient *rp
505 struct X400RediHist *hist1;
506 struct X400RediHist *hist2;
511 fprintf(stderr,
"Failed to allocate new trace info object \n");
522 "Failed to add X400_S_REDIRECTION_TIME to Redirection Hist\n");
528 "/cn=redihist/prmd=TestPRMD/admd=TestPRMD/C=gb",
532 "Failed to add X400_S_OR_ADDRESS to Redirection Hist\n");
542 "Failed to add X400_S_DIRECTORY_NAME to Redirection Hist\n");
552 "Failed to add X400_N_REDIRECTION_REASON to trace info\n");
560 fprintf(stderr,
"Failed to allocate new trace info object \n");
571 "Failed to add X400_S_REDIRECTION_TIME to Redirection Hist\n");
577 "/cn=redihist2/prmd=TestPRMD/admd=TestPRMD/C=gb",
581 "Failed to add X400_S_OR_ADDRESS to Redirection Hist\n");
591 "Failed to add X400_S_DIRECTORY_NAME to Redirection Hist\n");
601 "Failed to add X400_N_REDIRECTION_REASON to " 602 "Redirection Hist\n");
608 static int do_redi_hist_env(
609 struct X400mtMessage *msg
612 struct X400RediHist *hist1;
613 struct X400RediHist *hist2;
618 fprintf(stderr,
"Failed to allocate new trace info object \n");
629 "Failed to add X400_S_REDIRECTION_TIME to Redirection Hist\n");
635 "/cn=redihist/prmd=TestPRMD/admd=TestPRMD/C=gb",
639 "Failed to add X400_S_OR_ADDRESS to Redirection Hist\n");
649 "Failed to add X400_S_DIRECTORY_NAME to Redirection Hist\n");
659 "Failed to add X400_N_REDIRECTION_REASON to trace info\n");
667 fprintf(stderr,
"Failed to allocate new trace info object \n");
678 "Failed to add X400_S_REDIRECTION_TIME to Redirection Hist\n");
684 "/cn=redihist2/prmd=TestPRMD/admd=TestPRMD/C=gb",
688 "Failed to add X400_S_OR_ADDRESS to Redirection Hist\n");
698 "Failed to add X400_S_DIRECTORY_NAME to Redirection Hist\n");
708 "Failed to add X400_N_REDIRECTION_REASON to " 709 "Redirection Hist\n");
715 static void do_origandl(
716 struct X400mtMessage *msg
719 struct X400ORandDL *or_and_dl1;
720 struct X400ORandDL *or_and_dl2;
722 const char *origin_or_address =
"/cn=origandlorig/prmd=TestPRMD/admd=TestPRMD/C=gb/";
723 const char *origin_dn_address =
"CN=origandlorig,c=GB";
728 fprintf(stderr,
"Failed to allocate new OR Address and DL " 729 "expansion object \n");
740 "Failed to add X400_S_ORIG_OR_EXAP_TIME " 754 "Failed to add X400_S_OR_ADDRESS " 766 "Failed to add X400_S_DIRECTORY_NAME " 772 fprintf(stderr,
"Failed to allocate new OR Address and DL " 773 "expansion object \n");
784 "Failed to add X400_S_ORIG_OR_EXAP_TIME " 798 "Failed to add X400_S_OR_ADDRESS " 810 "Failed to add X400_S_DIRECTORY_NAME " #define X400_S_DIRECTORY_NAME
#define X400_S_ORIG_OR_EXAP_TIME
#define X400_S_CONVERTED_ENCODED_INFORMATION_TYPES
#define X400_N_IMPLICIT_CONVERSION_PROHIBITED
#define X400_S_SUBJECT_IDENTIFIER
#define X400_S_CONTENT_IDENTIFIER
X400COMMON_CDECL int X400RediHistAddIntParam(struct X400RediHist *hist, int paramtype, int value)
Set an integer value in a Redirection History object.
int X400mtOpen(const char *credentials, struct X400mtSession **spp)
Open a session to the MTA.
#define X400_S_ARRIVAL_TIME
int X400mtMsgNew(struct X400mtSession *sp, int type, struct X400mtMessage **mpp)
Creates new message.
#define X400_N_RESPONSIBILITY
#define X400_N_DL_EXPANSION_PROHIBITED
#define X400_SUBJECT_TRACE_INFO
#define X400_S_CONTENT_CORRELATOR_IA5_STRING
#define X400_S_SUPPLEMENTARY_INFO
#define X400_S_DSI_ARRIVAL_TIME
X400COMMON_CDECL int X400ORandDLAddStrParam(struct X400ORandDL *or_and_dl, int type, const char *value, size_t length)
Add string parameter for a Originator and DL Expansion History object.
#define X400_N_CONVERSION_WITH_LOSS_PROHIBITED
int X400mtRecipNew(struct X400mtMessage *mp, int type, struct X400Recipient **rpp)
Add new recipient to a message.
#define X400_N_RECIPIENT_REASSIGNMENT_PROHIBITED
int X400mtRediHistNewEnv(struct X400mtMessage *msg, struct X400RediHist **hist)
Create a new Redirection History object for a message envelope this is represented by 8...
int X400mtMsgAddIntParam(struct X400mtMessage *mp, int paramtype, int value)
Add integer-valued parameter to the message.
int X400mtRecipAddStrParam(struct X400Recipient *rp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
int X400mtRecipAddIntParam(struct X400Recipient *rp, int paramtype, int value)
Add integer-valued parameter to the message.
#define X400_S_REDIRECTION_TIME
#define X400_S_OR_ADDRESS
#define X400_N_CONTENT_TYPE
#define X400_S_MESSAGE_IDENTIFIER
const char * X400mtError(int error)
Return string for error code.
int X400mtMsgSend(struct X400mtMessage *mp)
Send message object to MTA.
#define X400_N_DISCLOSURE
#define X400_S_GLOBAL_DOMAIN_ID
#define X400_S_LATEST_DELIVERY_TIME
#define X400_N_REPORT_REQUEST
int X400mtORandDLNew(struct X400mtMessage *msg, struct X400ORandDL **or_and_dl)
Create new Originator and DL expansion history object.
#define X400_N_NON_DELIVERY_REASON
X400COMMON_CDECL int X400TraceInfoAddStrParam(struct X400TraceInfo *info, int paramtype, const char *value, size_t length)
Add string-valued parameter to the X400TraceInfo object.
int X400mtMsgAddStrParam(struct X400mtMessage *mp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
int X400mtClose(struct X400mtSession *sp)
Close a X400 Session.
#define X400_N_ORIGINAL_RECIPIENT_NUMBER
int X400mtTraceInfoNew(struct X400mtMessage *mp, struct X400TraceInfo **info, int type)
Create a new Trace Info object for a message object.
#define X400_RR_RECIP_ASSIGNED_ALT_RECIP
#define X400_N_ALTERNATE_RECIPIENT_ALLOWED
X400COMMON_CDECL int X400RediHistAddStrParam(struct X400RediHist *hist, int paramtype, const char *value, size_t length)
Add string-valued parameter to the X400RediHist object.
#define X400_RECIP_ENVELOPE
X400COMMON_CDECL int X400RediHistNew(struct X400Recipient *recip, struct X400RediHist **hist)
Create a new Redirection History object.
#define X400_S_DSI_ATTEMPTED_DOMAIN
#define X400_N_MTA_REPORT_REQUEST
#define X400_N_NON_DELIVERY_DIAGNOSTIC
#define X400_N_REDIRECTION_REASON
#define X400_S_DSI_AA_DEF_TIME
#define X400_N_CONTENT_RETURN_REQUEST
#define X400_RECIP_REPORT
int X400mtMsgDelete(struct X400mtMessage *mp)
Delete message object.
#define X400_S_MESSAGE_DELIVERY_TIME