Summary: Isode provides a number of APIs which allow integrators and product developers to build components that access the Isode Messaging server products or other products supporting the same protocols.
x400_mtsend.c
1 /* Copyright (c) 2003-2013, Isode Limited, London, England.
2  * All rights reserved.
3  *
4  * Acquisition and use of this software and related materials for any
5  * purpose requires a written licence agreement from Isode Limited,
6  * or a written licence from an organisation licenced by Isode Limited
7  * to grant such a licence.
8  *
9  */
10 
11 /*
12  *
13  * @VERSION@
14  * Simple example program for transferring a message into the MTA
15  */
16 
17 /* If you want to use raw content, remove the undef.
18  * NB you will then need to put some content into <cwd>/p22
19  */
20 #define USE_RAW_CONTENT 1
21 #undef USE_RAW_CONTENT
22 
23 #include <stdio.h>
24 #include <stdlib.h>
25 
26 
27 #include <x400_mtapi.h>
28 #include <seclabel_api.h> /* For security labels */
29 #include "example.h"
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 #include <fcntl.h>
33 #include <errno.h>
34 #include <time.h>
35 
36 
37 /* local functions */
38 static int send_msgs(
39  int argc,
40  char **argv
41 ) ;
42 static int send_msg(
43  struct X400mtSession *sp
44 );
45 static int add_single_recip(
46  struct X400mtMessage *mp
47 );
48 static int add_primary_recip(
49  struct X400mtMessage *mp
50 );
51 static int add_exempt_address(
52  struct X400mtMessage *mp
53 );
54 static int add_address_list_indicator(
55  struct X400mtMessage *mp
56 );
57 
58 static int add_handling_instructions(
59  struct X400mtMessage *mp
60 );
61 
62 #ifdef add_multi_recips
63 static int add_multi_recips(
64  struct X400mtMessage *mp
65 );
66 static int add_content_recip_info(
67  struct X400Recipient *rp,
68  const char *free_form_name
69 );
70 #endif
71 static int build_env(
72  struct X400mtMessage *mp
73 );
74 static int build_content(
75  struct X400mtMessage *mp
76 );
77 static int add_binary_bp(
78  struct X400mtMessage *mp
79 );
80 static int add_env_recip_info(
81  struct X400Recipient *rp
82 );
83 static void usage(void);
84 
85 static char * set_latest_del_time(void);
86 static int rno = 1;
87 static int fwd_rno = 1;
88 
89 static int load_ber(
90  char *filename,
91  char **output_buffer,
92  int *buf_len
93 );
94 #define ADD_FWD_BODYPART 1
95 #ifdef ADD_FWD_BODYPART
96 static int add_fwd_bodypart(
97  struct X400mtMessage *mp
98 );
99 
100 static int build_fwd_env (
101  struct X400Message *mp
102 );
103 
104 static int build_fwd_content (
105  struct X400Message *mp
106 );
107 
108 static int add_fwd_recip(
109  struct X400Message *mp,
110  const char *oraddress,
111  int type
112 );
113 
114 static int create_fw_message(
115  struct X400Message *mp
116 );
117 
118 static int add_fwd_content_bodypart (
119  struct X400mtMessage *mp
120 );
121 
122 static int add_dl_exempted_recip_list (
123  struct X400mtMessage *mp
124 );
125 
126 #endif
127 
128 
129 /* These are the data items used */
130 
131 /* The O/R addresses used are intended to be compatible with those
132  * used in the quick install scripts mktailor.tcl, and createmhs.tcl.
133  * (createmhs.tcl is used by x400quick).
134  * Change this value to the name of your host. */
135 #define HOSTNAME "dhcp-165"
136 
137 /* define USE_P772_EXTS here, if you want to send a message using P772
138  * military messaging extensions.
139  */
140 #define USE_P772_EXTS 1
141 #ifdef USE_P772_EXTS
142 /* P772 extensions use an external content type */
143 #define WANT_EXTERNAL_CONTENT_TYPE 1
144 #endif
145 static char *optstr = "uG:O:r:g:G:c:l:R:y:C:iaqsAvf:X:S:";
146 
147 /* this value is used for the originator of the message */
148 /* static const char orig[] = "/S=x400test-orig/OU="HOSTNAME"/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/"; */
149 static const char *orig;
150 
151 static const char *fwd_orig;
152 static const char *fwd_recip;
153 
154 static const char orig_ret_addr[] = "/S=x400test-orig/OU="HOSTNAME"/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
155 
156 /* default recipients */
157 /* static const char recip[] = "/S=x400test-recip/OU="HOSTNAME"/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/"; */
158 static char *recip;
159 static char *exemp_recip;
160 
161 static const char recip2[] = "/S=x400test-recip2/OU="HOSTNAME"/O=GatewayMTA/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
162 /* This recip will cause a report to be generated */
163 static const char badrecip[] = "/S=x400test-recip2/OU=badhost/O=TestOrg/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
164 static const char auth_orig[] = "/S=x400test-auth-orig/OU="HOSTNAME"/O=TestOrg/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
165 
166 /* envelope recip values */
167 static const char orar[] = "/S=x400test-orig-orar/OU="HOSTNAME"/O=TestOrg/PRMD=TestPRMD/ADMD=TestADMD/C=GB/";
168 
169 static const char orardn[] = "CN=alternative,c=gb";
170 
171 /* default envelope integer values */
172 #ifdef WANT_EXTERNAL_CONTENT_TYPE
173 static char *def_ext_content_type = "1.3.26.0.4406.0.4.1";
174 #endif
175 static int def_bool = 0;
176 static int def_priority = 2;
177 
178 /* default envelope string values */
179 static const char def_msgid[] = "P772 MessageType identifier";
180 static const char def_utc[] = "050924120000";
181 /* Make sure the second part of msg_id (after ";") is less than 32 chars in length */
182 static const char msg_id[] = "/PRMD=TestPRMD/ADMD=TestADMD/C=GB/;"HOSTNAME".2810401";
183 static const char content_id[] = "030924.140212";
184 static const char fwd_msg_id[] = "/PRMD=TestFWDPRMD/ADMD=TestADMD/C=GB/;"HOSTNAME".2810401";
185 
186 
187 static const char distvalue1[] = { 0x02, 0x01, 0x0a };
188 
189 static const char distvalue2[] = { 0x13, 0x0a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a};
190 
191 static const char corr_octet[] = { 0x02, 0x01, 0x0a };
192 
193 /* default content integer types */
194 static const int importance = 2;
195 static const int sensitivity = 3;
196 static const int autoforwarded = 1;
197 
198 /* default content string types */
199 static const char text[] = "First line\r\nSecond line\r\n";
200 static const char ipm_id[] = "1064400656.24922*";
201 static const char ipm_rep_id[] = "1064400656.24923*";
202 static const char ipm_obs_id[] = "1064400656.24924*";
203 static const char ipm_rel_id[] = "1064400656.24925*";
204 static const char orig_ref[] = "orig-ref-val";
205 
206 
207 #define XML_BUFSIZE 1024
208 #define STRING_BUFSIZE 1024
209 
213 int main (
214  int argc,
215  char **argv
216 )
217 {
218  return send_msgs (argc, argv);
219 }
220 
221 static int send_msgs (
222  int argc,
223  char **argv
224 )
225 {
226  int status;
227  struct X400mtSession *sp;
228 
229  if (get_args(argc, argv, optstr)) {
230  usage();
231  exit(-1);
232  }
233 
234  orig = strdup(x400_default_gw_originator);
235  recip = strdup(x400_default_gw_recipient);
236  exemp_recip = strdup(x400_default_exempted_recipient);
237  fwd_orig = strdup(x400_default_fwd_originator);
238  fwd_recip = strdup(x400_default_fwd_recipient);
239 
240  if (x400_channel == NULL) {
241  fprintf (stderr, "No x400_channel value set in x400tailor file");
242  exit(1);
243  }
244 
245  /* open a new session */
246  status = X400mtOpen (x400_channel, &sp);
247  if ( status != X400_E_NOERROR ) {
248  fprintf (stderr, "Error in Open: %s\n", X400mtError (status));
249  exit (status);
250  }
251 
252  /* setup logging from $(ETCDIR)x400api.xml or $(SHAREDIR)x400api.xml */
253  X400mtSetStrDefault(sp, X400_S_LOG_CONFIGURATION_FILE, "x400api.xml", 0);
254 
255  /* Set the ADatP3 seperator */
256  X400mtSetStrDefault(sp, X400_ADATP3_SEP,"\r\n",-1);
257 
258 
259  while (num_msgs_to_send-- > 0)
260  {
261  status = send_msg(sp);
262  if ( status != X400_E_NOERROR ) {
263  fprintf (stderr, "Error in send_msg: %s\n", X400mtError (status));
264  exit (status);
265  }
266  }
267 
268  /* close the API session */
269  return X400mtClose (sp);
270 }
271 
272 static int send_msg(
273  struct X400mtSession *sp
274 )
275 {
276  int status;
277  struct X400mtMessage *mp;
278 
279  /* start preparing a new message */
280  status = X400mtMsgNew (sp, X400_MSG_MESSAGE, &mp);
281  /* Should report all errors as above */
282  if ( status != X400_E_NOERROR ) exit (status);
283 
284  /* setup originator using a single string */
285  printf("originator of msg is %s\n", orig);
286  status = X400mtMsgAddStrParam (mp, X400_S_OR_ADDRESS, orig, -1);
287  if ( status != X400_E_NOERROR ) exit (status);
288 
289  /* add various envelope and header recipients into the message */
290  /* status = add_multi_recips(mp); */
291  status = add_single_recip(mp);
292  if ( status != X400_E_NOERROR ) exit (status);
293 
294  status = add_primary_recip(mp);
295  if ( status != X400_E_NOERROR ) exit (status);
296 
297  /* build rest of the message envelope */
298  status = build_env(mp);
299  if ( status != X400_E_NOERROR ) exit (status);
300 
301  /* build the message content */
302  status = build_content(mp);
303  if ( status != X400_E_NOERROR ) exit (status);
304 
305 #ifdef HANDLING_MILITARY_IPN
306  /* Add ACP127 Notification response. This is only valid in a Military Notification */
307  {
308  struct X400ACP127Resp *resp = NULL;
309  struct X400ALI *ali1 = NULL;
310  struct X400ALI *ali2 = NULL;
311 
312  /* Create new ACP127 Response object */
313  status = X400mtACP127RespNew(mp,&resp);
314  if ( status != X400_E_NOERROR ) return (status);
315 
316  /* Add Response type */
318  if ( status != X400_E_NOERROR ) return (status);
319 
320 
322  if ( status != X400_E_NOERROR ) return (status);
323 
324 
326  if ( status != X400_E_NOERROR ) return (status);
327 
328 
329  /* Add ACP127 response time*/
330  status = X400ACP127RespAddStrParam (resp,
332  "080101120000+0100",
333  -1);
334  if ( status != X400_E_NOERROR ) return (status);
335 
336 
337  /* Add ACP127 response recipient*/
338  status = X400ACP127RespAddStrParam (resp,
340  "ACP127 Recipient",
341  -1);
342  if ( status != X400_E_NOERROR ) return (status);
343 
344  /* Add ACP127 supplimentry info*/
345  status = X400ACP127RespAddStrParam (resp,
347  "ACP127 supp info",
348  -1);
349  if ( status != X400_E_NOERROR ) return (status);
350 
351  /* Add ACP127 Address List Indicator */
352  status = X400ACP127RespNewALI (resp,&ali1);
353  if ( status != X400_E_NOERROR ) return (status);
354 
355  status = X400ALIAddIntParam (ali1,X400_N_ALI_TYPE,0);
356  if ( status != X400_E_NOERROR ) return (status);
357 
359  if ( status != X400_E_NOERROR ) return (status);
360 
362  if ( status != X400_E_NOERROR ) return (status);
363 
364  status = X400ALIAddStrParam (ali1, X400_S_OR_ADDRESS,
365  "/cn=acp127ali1/PRMD=TestPRMD/ADMD=TestADMD/C=GB", -1);
366  if ( status != X400_E_NOERROR ) return (status);
367 
369  "cn=acp127ali1,c=gb", -1);
370  if ( status != X400_E_NOERROR ) return (status);
371 
373  "ACP127 Mr Address List Indicator1", -1);
374  if ( status != X400_E_NOERROR ) return (status);
375 
376  status = X400ALIAddStrParam (ali1, X400_S_TELEPHONE_NUMBER,"1270123456789",-1);
377  if ( status != X400_E_NOERROR ) return (status);
378 
379  /*Add a second ACP127 Address List indicator */
380  status = X400ACP127RespNewALI (resp,&ali2);
381  if ( status != X400_E_NOERROR ) return (status);
382 
383  status = X400ALIAddIntParam (ali2,X400_N_ALI_TYPE,1);
384  if ( status != X400_E_NOERROR ) return (status);
385 
387  if ( status != X400_E_NOERROR ) return (status);
388 
390  if ( status != X400_E_NOERROR ) return (status);
391 
392  status = X400ALIAddStrParam (ali2, X400_S_OR_ADDRESS,
393  "/cn=acp127ali2/PRMD=TestPRMD/ADMD=TestADMD/C=GB", -1);
394  if ( status != X400_E_NOERROR ) return (status);
395 
397  "cn=acp127ali2,c=gb", -1);
398  if ( status != X400_E_NOERROR ) return (status);
399 
401  "ACP127 Mr Address List Indicator2", -1);
402  if ( status != X400_E_NOERROR ) return (status);
403 
404  status = X400ALIAddStrParam (ali2, X400_S_TELEPHONE_NUMBER,"1270123456789",-1);
405  if ( status != X400_E_NOERROR ) return (status);
406 
407  }
408 #endif
409  /* send the message */
410  status = X400_E_TEMPORARY_ERROR;
411 
412  while (status == X400_E_TEMPORARY_ERROR) {
413  status = X400mtMsgSend (mp);
414  if (status == X400_E_TEMPORARY_ERROR) {
415  char foo[100];
416  fprintf (stderr, "Temporary error in MsgSend: %s\n", X400mtError (status));
417  printf("Press return to try again > ");
418  ic_fgets (foo, sizeof foo, stdin);
419  } else if ( status != X400_E_NOERROR ) {
420  fprintf (stderr, "Error in MsgSend: %s\n", X400mtError (status));
421  exit (status);
422  }
423  }
424 
425  /* delete the message structure */
426  status = X400mtMsgDelete (mp);
427  if ( status != X400_E_NOERROR ) exit (status);
428 
429  return status;
430 }
431 
432 static int add_primary_recip(
433  struct X400mtMessage *mp
434 )
435 {
436  struct X400Recipient *rp;
437  int status;
438 
439  printf("Adding primary recip with only FreeForm name\n");
440  /* add new recipient to message */
442 
443  status = X400mtRecipAddStrParam (rp, X400_S_FREE_FORM_NAME, "Fred Bloggs", -1);
444  if ( status != X400_E_NOERROR ) return (status);
445 
446  return status;
447 }
448 
449 static int add_single_recip(
450  struct X400mtMessage *mp
451 )
452 {
453  struct X400Recipient *rp;
454  int status;
455 
456  printf("Adding single recip %s\n", recip);
457  /* add new recipient to message */
458  status = X400mtRecipNew (mp, X400_RECIP_STANDARD, &rp);
459  if ( status != X400_E_NOERROR ) return (status);
460  /* give recip an address */
461  status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip, -1);
462  if ( status != X400_E_NOERROR ) return (status);
463  /* add other values to recip */
464  status = add_env_recip_info (rp);
465  if ( status != X400_E_NOERROR ) return (status);
466 
467  /* Add an X.411 DL exempted recipient list */
468  status = add_dl_exempted_recip_list (mp);
469  if ( status != X400_E_NOERROR ) return (status);
470 
471 
472 #define USE_REDIRECTION_HISTORY 1
473 #ifdef USE_REDIRECTION_HISTORY
474  {
475  struct X400RediHist *hist1;
476  struct X400RediHist *hist2;
477 
478  status = X400RediHistNew(rp,&hist1);
479  if (status !=X400_E_NOERROR) {
480  fprintf(stderr,"Failed to allocate new redirection history object \n");
481  exit(status);
482  }
483 
484  /* Add Redirection History time */
485  status = X400RediHistAddStrParam (hist1,
487  "071121125704Z",
488  -1);
489  if (status !=X400_E_NOERROR) {
490  fprintf(stderr,
491  "Failed to add X400_S_REDIRECTION_TIME to Redirection Hist\n");
492  exit(status);
493  }
494 
495  status = X400RediHistAddStrParam (hist1,
497  "/cn=redihist/prmd=TestPRMD/admd=TestPRMD/C=gb",
498  -1);
499  if (status !=X400_E_NOERROR) {
500  fprintf(stderr,
501  "Failed to add X400_S_OR_ADDRESS to Redirection Hist\n");
502  exit(status);
503  }
504 
505  status = X400RediHistAddStrParam (hist1,
507  "CN=redihist,c=GB",
508  -1);
509  if (status !=X400_E_NOERROR) {
510  fprintf(stderr,
511  "Failed to add X400_S_DIRECTORY_NAME to Redirection Hist\n");
512  exit(status);
513  }
514 
515 
516  status = X400RediHistAddIntParam(hist1,
518  X400_RR_ALIAS);
519  if (status !=X400_E_NOERROR) {
520  fprintf(stderr,
521  "Failed to add X400_N_REDIRECTION_REASON to trace info\n");
522  exit(status);
523  }
524 
525  /*hist2*/
526 
527  status = X400RediHistNew(rp,&hist2);
528  if (status !=X400_E_NOERROR) {
529  fprintf(stderr,"Failed to allocate new trace info object \n");
530  exit(status);
531  }
532 
533  /* Add Redirection History time */
534  status = X400RediHistAddStrParam (hist2,
536  "071121125714Z",
537  -1);
538  if (status !=X400_E_NOERROR) {
539  fprintf(stderr,
540  "Failed to add X400_S_REDIRECTION_TIME to Redirection Hist\n");
541  exit(status);
542  }
543 
544  status = X400RediHistAddStrParam (hist2,
546  "/cn=redihist2/prmd=TestPRMD/admd=TestPRMD/C=gb",
547  -1);
548  if (status !=X400_E_NOERROR) {
549  fprintf(stderr,
550  "Failed to add X400_S_OR_ADDRESS to Redirection Hist\n");
551  exit(status);
552  }
553 
554  status = X400RediHistAddStrParam (hist2,
556  "CN=redihist2,c=GB",
557  -1);
558  if (status !=X400_E_NOERROR) {
559  fprintf(stderr,
560  "Failed to add X400_S_DIRECTORY_NAME to Redirection Hist\n");
561  exit(status);
562  }
563 
564 
565  status = X400RediHistAddIntParam(hist2,
568  if (status !=X400_E_NOERROR) {
569  fprintf(stderr,
570  "Failed to add X400_N_REDIRECTION_REASON to "
571  "Redirection Hist\n");
572  exit(status);
573  }
574 
575 }
576 #endif
577 
578 #ifdef USE_P772_EXTS
579  /* Add ACP 127 Notification types */
580  status = X400mtRecipAddIntParam (rp,
583  if ( status != X400_E_NOERROR ) return (status);
584 
585 
586  status = X400mtRecipAddIntParam (rp,
589  if ( status != X400_E_NOERROR ) return (status);
590 
591  status = X400mtRecipAddIntParam (rp,
594  if ( status != X400_E_NOERROR ) return (status);
595 
596 #endif
597 
598  return X400_E_NOERROR;
599 }
600 
601 static int add_exempt_address(
602  struct X400mtMessage *mp
603 )
604 {
605  struct X400Recipient *rp;
606  struct X400Recipient *rp2;
607  int status;
608  printf("Adding exempted recip %s\n", exemp_recip);
609  /* add new recipient to message */
610  status = X400mtRecipNew (mp, X400_EXEMPTED_ADDRESS, &rp);
611  if ( status != X400_E_NOERROR ) return (status);
612  /* give exempted recip an address */
614  exemp_recip, -1);
615  if ( status != X400_E_NOERROR ) return (status);
616 
618  "cn=exemprecip,c=gb", -1);
619  if ( status != X400_E_NOERROR ) return (status);
620 
622  "Mr Exempted", -1);
623  if ( status != X400_E_NOERROR ) return (status);
624 
626  "0123456789", -1);
627  if ( status != X400_E_NOERROR ) return (status);
628 
629  /* Add second exempted recipient */
630  status = X400mtRecipNew (mp, X400_EXEMPTED_ADDRESS, &rp2);
631  if ( status != X400_E_NOERROR ) return (status);
632 
634  "/CN=exemp2/PRMD=TestPRMD/ADMD=TestADMD/C=GB", -1);
635  if ( status != X400_E_NOERROR ) return (status);
636 
637  return X400_E_NOERROR;
638 }
639 static int add_address_list_indicator(
640  struct X400mtMessage *mp
641 )
642 {
643  struct X400ALI *ali = NULL;
644  struct X400ALI *ali2 = NULL;
645  int status;
646 
647  printf("Adding address list indicators\n");
648 
649  /* add new Address List Indicator to message */
650  status = X400mtALINew (mp,&ali);
651  if ( status != X400_E_NOERROR ) return (status);
652 
653  status = X400ALIAddIntParam (ali,X400_N_ALI_TYPE,0);
654  if ( status != X400_E_NOERROR ) return (status);
655 
657  if ( status != X400_E_NOERROR ) return (status);
658 
660  if ( status != X400_E_NOERROR ) return (status);
661 
662  status = X400ALIAddStrParam (ali, X400_S_OR_ADDRESS,
663  "/cn=ALI1/PRMD=TestPRMD/ADMD=TestADMD/C=GB", -1);
664  if ( status != X400_E_NOERROR ) return (status);
665 
667  "cn=ali1,c=gb", -1);
668  if ( status != X400_E_NOERROR ) return (status);
669 
671  "Mr Address List Indicator1", -1);
672  if ( status != X400_E_NOERROR ) return (status);
673 
674  status = X400ALIAddStrParam (ali, X400_S_TELEPHONE_NUMBER,"0123456789", -1);
675  if ( status != X400_E_NOERROR ) return (status);
676 
677  /* Add second exempted recipient */
678  status = X400mtALINew (mp, &ali2);
679  if ( status != X400_E_NOERROR ) return (status);
680 
681  status = X400ALIAddStrParam (ali2, X400_S_OR_ADDRESS,
682  "/CN=ALI2/PRMD=TestPRMD/ADMD=TestADMD/C=GB", -1);
683  if ( status != X400_E_NOERROR ) return (status);
684 
685  status = X400ALIAddIntParam (ali2,X400_N_ALI_TYPE,1);
686  if ( status != X400_E_NOERROR ) return (status);
687  status = X400ALIAddStrParam (ali2, X400_S_OR_ADDRESS,
688  "/cn=ALI2/PRMD=TestPRMD/ADMD=TestADMD/C=GB", -1);
689  if ( status != X400_E_NOERROR ) return (status);
690 
692  "cn=ali2,c=gb", -1);
693  if ( status != X400_E_NOERROR ) return (status);
694 
695 
696 
697  return X400_E_NOERROR;
698 }
699 
700 static int add_handling_instructions(
701  struct X400mtMessage *mp
702 )
703 {
704  struct X400PSS *pss = NULL; /* Printable String Sequence object */
705  struct X400PSS *pss2 = NULL;
706  int status;
707 
708  printf("Adding handling instructions\n");
709 
710  /* add new Address List Indicator to message */
711  status = X400mtPSSNew (mp,X400_S_HANDLING_INSTRUCTIONS,&pss);
712  if ( status != X400_E_NOERROR ) return (status);
713 
714 
715  status = X400PSSAddStrParam (pss,
716  "Handling instruction1",
717  -1);
718  if ( status != X400_E_NOERROR ) return (status);
719 
720 
721  status = X400mtPSSNew (mp,X400_S_HANDLING_INSTRUCTIONS,&pss2);
722  if ( status != X400_E_NOERROR ) return (status);
723 
724 
725  status = X400PSSAddStrParam (pss2,
726  "Handling instruction2",
727  -1);
728  if ( status != X400_E_NOERROR ) return (status);
729 
730 
731  return X400_E_NOERROR;
732 }
733 
734 static int add_message_instructions(
735  struct X400mtMessage *mp
736 )
737 {
738  struct X400PSS *pss = NULL; /* Printable String Sequence object */
739  struct X400PSS *pss2 = NULL;
740  int status;
741 
742  printf("Adding Message instructions\n");
743 
744  /* add new Address List Indicator to message */
745  status = X400mtPSSNew (mp,X400_S_MESSAGE_INSTRUCTIONS,&pss);
746  if ( status != X400_E_NOERROR ) return (status);
747 
748 
749  status = X400PSSAddStrParam (pss,
750  "Message instruction1",
751  -1);
752  if ( status != X400_E_NOERROR ) return (status);
753 
754 
755  status = X400mtPSSNew (mp,X400_S_MESSAGE_INSTRUCTIONS,&pss2);
756  if ( status != X400_E_NOERROR ) return (status);
757 
758 
759  status = X400PSSAddStrParam (pss2,
760  "Message instruction2",
761  -1);
762  if ( status != X400_E_NOERROR ) return (status);
763 
764 
765  return X400_E_NOERROR;
766 }
767 
768 static int add_dist_codes_sic(
769  struct X400mtMessage *mp
770 )
771 {
772  struct X400PSS *pss = NULL; /* Printable String Sequence object */
773  struct X400PSS *pss2 = NULL;
774  struct X400DistField *distfield1 = NULL;
775  struct X400DistField *distfield2 = NULL;
776  int status;
777 
778  printf("Adding Distribution Codes\n");
779 
780  /* Add new SIC */
781  status = X400mtPSSNew (mp,X400_S_DIST_CODES_SIC,&pss);
782  if ( status != X400_E_NOERROR ) return (status);
783 
784 
785  status = X400PSSAddStrParam (pss,
786  "dist code 1",
787  -1);
788  if ( status != X400_E_NOERROR ) return (status);
789 
790  /* Add second SIC */
791  status = X400mtPSSNew (mp,X400_S_DIST_CODES_SIC,&pss2);
792  if ( status != X400_E_NOERROR ) return (status);
793 
794 
795  status = X400PSSAddStrParam (pss2,
796  "dist code 2",
797  -1);
798  if ( status != X400_E_NOERROR ) return (status);
799 
800  /* Add new Distribution Extension Field */
801  status = X400mtDistFieldNew (mp,&distfield1);
802  if ( status != X400_E_NOERROR ) return (status);
803 
804 
805  status = X400DistFieldAddStrParam (distfield1,
807  "1.2.3.4.5",
808  -1);
809  if ( status != X400_E_NOERROR ) return (status);
810 
811  status = X400DistFieldAddStrParam (distfield1,
813  distvalue1, 3);
814  if ( status != X400_E_NOERROR ) return (status);
815 
816  /* Add second SIC */
817  status = X400mtDistFieldNew (mp,&distfield2);
818  if ( status != X400_E_NOERROR ) return (status);
819 
820 
821  status = X400DistFieldAddStrParam (distfield2,
823  "1.2.3.4.5.6",
824  -1);
825  if ( status != X400_E_NOERROR ) return (status);
826 
827  status = X400DistFieldAddStrParam (distfield2,
829  distvalue2, 12);
830  if ( status != X400_E_NOERROR ) return (status);
831 
832 
833  return X400_E_NOERROR;
834 }
835 
836 static int add_other_recipient_indicator(
837  struct X400mtMessage *mp
838 )
839 {
840  struct X400OtherRecip *rp = NULL;
841  struct X400OtherRecip *rp2 = NULL;
842  int status;
843 
844  printf("Adding Other Recipient Indicators\n");
845 
846  /* Add new Other recipient */
847  status = X400mtOtherRecipNew (mp,&rp);
848  if ( status != X400_E_NOERROR ) return (status);
849 
850 
851  status = X400OtherRecipAddStrParam (rp,"other recip 1",-1);
852  if ( status != X400_E_NOERROR ) return (status);
853 
854 
855  status = X400OtherRecipAddIntParam (rp,1);
856  if ( status != X400_E_NOERROR ) return (status);
857 
858 
859  /* Add second Other recipient */
860  status = X400mtOtherRecipNew (mp,&rp2);
861  if ( status != X400_E_NOERROR ) return (status);
862 
863 
864  status = X400OtherRecipAddStrParam (rp2,"other recip 2",-1);
865  if ( status != X400_E_NOERROR ) return (status);
866 
867 
868  status = X400OtherRecipAddIntParam (rp2,0);
869  if ( status != X400_E_NOERROR ) return (status);
870 
871 
872 
873  return X400_E_NOERROR;
874 }
875 #ifdef add_multi_recips
876 static int add_multi_recips(
877  struct X400mtMessage *mp
878 )
879 {
880  struct X400Recipient *rp;
881  int status;
882 
883  printf("Adding multiple recips\n");
884  /* add new recipient to message */
885  status = X400mtRecipNew (mp, X400_RECIP_STANDARD, &rp);
886  if ( status != X400_E_NOERROR ) return (status);
887  /* give recip an address */
888  status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip, -1);
889  if ( status != X400_E_NOERROR ) return (status);
890  /* add other values to recip */
891  status = add_env_recip_info (rp);
892  if ( status != X400_E_NOERROR ) return (status);
893 
894  /* add second recipient to message */
895  status = X400mtRecipNew (mp, X400_RECIP_STANDARD, &rp);
896  if ( status != X400_E_NOERROR ) exit (status);
897  /* give recip an address */
898  status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip2, -1);
899  if ( status != X400_E_NOERROR ) return (status);
901  rno++;
902  if ( status != X400_E_NOERROR ) return (status);
903 
904  /* add bad recipient to message */
905  status = X400mtRecipNew (mp, X400_RECIP_STANDARD, &rp);
906  if ( status != X400_E_NOERROR ) exit (status);
907  /* give recip an address */
908  status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, badrecip, -1);
909  if ( status != X400_E_NOERROR ) return (status);
911  rno++;
912  if ( status != X400_E_NOERROR ) return (status);
913 
914  /* add cc recipient to message */
915  status = X400mtRecipNew (mp, X400_RECIP_CC, &rp);
916  if ( status != X400_E_NOERROR ) exit (status);
917  /* give recip an address */
918  status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip, -1);
919  if ( status != X400_E_NOERROR ) return (status);
920  /* add other values to recip */
921  status = add_content_recip_info (rp, recip);
922  if ( status != X400_E_NOERROR ) return (status);
923 
924  /* add second cc recipient to message */
925  status = X400mtRecipNew (mp, X400_RECIP_CC, &rp);
926  if ( status != X400_E_NOERROR ) exit (status);
927  /* give recip an address */
928  status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip2, -1);
929  if ( status != X400_E_NOERROR ) return (status);
930  /* add other values to recip */
931  status = add_content_recip_info (rp, recip2);
932  if ( status != X400_E_NOERROR ) return (status);
933 
934  /* add bcc recipient to message */
935  status = X400mtRecipNew (mp, X400_RECIP_BCC, &rp);
936  if ( status != X400_E_NOERROR ) exit (status);
937  /* give recip an address */
938  status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip2, -1);
939  if ( status != X400_E_NOERROR ) return (status);
940 
941  /* add reply recipient to message */
942  status = X400mtRecipNew (mp, X400_RECIP_REPLY, &rp);
943  if ( status != X400_E_NOERROR ) exit (status);
944  /* give recip an address */
945  status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, recip2, -1);
946  if ( status != X400_E_NOERROR ) return (status);
947 
948  /* add auth user to message */
949  status = X400mtRecipNew (mp, X400_AUTH_ORIG, &rp);
950  if ( status != X400_E_NOERROR ) return (status);
951  /* give auth user an address */
952  status = X400mtRecipAddStrParam (rp, X400_S_OR_ADDRESS, auth_orig, -1);
953  if ( status != X400_E_NOERROR ) return (status);
954 
955  return X400_E_NOERROR;
956 }
957 #endif
958 
959 static int build_env(
960  struct X400mtMessage *mp
961 )
962 {
963  int status;
964 
965  /* Envelope Attributes */
966 
967 #ifdef WANT_EXTERNAL_CONTENT_TYPE
969  def_ext_content_type, -1);
970  if ( status != X400_E_NOERROR ) return (status);
971 #endif
972 
973 #ifdef WANT_DL_EXP_HIST
974  /*Add a DL expansion history*/
975  {
976  struct X400DLExpHist *hist;
977  status = X400mtDLExpHistNew (mp, &hist);
978  if ( status != X400_E_NOERROR ) return (status);
979 
980  status = X400DLExpHistAddStrParam (hist,
982  x400_default_gw_dlexphist1_or,
983  -1);
984  if ( status != X400_E_NOERROR ) return (status);
985 
986  status = X400DLExpHistAddStrParam (hist,
988  x400_default_gw_dlexphist1_dn,
989  -1);
990  if ( status != X400_E_NOERROR ) return (status);
991 
992  status = X400DLExpHistAddStrParam (hist,
994  "070801120000+0100",
995  -1);
996  if ( status != X400_E_NOERROR ) return (status);
997 
998 
999  status = X400mtDLExpHistNew (mp, &hist);
1000  if ( status != X400_E_NOERROR ) return (status);
1001 
1002  status = X400DLExpHistAddStrParam (hist,
1004  x400_default_gw_dlexphist2_or,
1005  -1);
1006  if ( status != X400_E_NOERROR ) return (status);
1007 
1008  status = X400DLExpHistAddStrParam (hist,
1010  x400_default_gw_dlexphist2_dn,
1011  -1);
1012  if ( status != X400_E_NOERROR ) return (status);
1013 
1014  status = X400DLExpHistAddStrParam (hist,
1016  "070801120000+0100",
1017  -1);
1018  if ( status != X400_E_NOERROR ) return (status);
1019 
1020 
1021  }
1022 #endif
1023 
1024 
1025 #ifdef USE_SEC_LABEL
1026  {
1027  /*If you are going to use security labels,
1028  *make sure the following variable points to the relevant xml file
1029  */
1030  const char* xml_filename = "seclabel.xml";
1031  char xml_content[XML_BUFSIZE];
1032  char str_content[STRING_BUFSIZE];
1033  int str_len = STRING_BUFSIZE;
1034  FILE *fd = NULL;
1035 
1036  /* Read in the security label XML file */
1037  fd = fopen(xml_filename,"r");
1038  if(fd == NULL) {
1039  fprintf(stderr,"Failed to open %s : %s\n",
1040  xml_filename,strerror(errno));
1041  }
1042 
1043  fread(&xml_content,XML_BUFSIZE,1,fd);
1044 
1045  fclose(fd);
1046 
1047  status = SecLabelInit("Example program");
1048  if (status != SECLABEL_E_NOERROR) {
1049  fprintf(stderr, "SecLabelInit returned error %d\n", status);
1050  exit(1);
1051  }
1052 
1053  /* Use SecLabelParse to turn the XML into an octet string */
1054  status = SecLabelParse(xml_content,
1055  str_content,
1056  STRING_BUFSIZE,
1057  &str_len);
1058 
1059  if (status != SECLABEL_E_NOERROR) {
1060  fprintf(stderr, "SecLabelParse returned error %d\n", status);
1061  exit(1);
1062  }
1063 
1064  /* Add the octet string to the message pointer */
1066  str_content,str_len);
1067  if ( status != X400_E_NOERROR ) {
1068  fprintf (stderr, "x400mtMsgAddStrParam returned error: %s\n", X400mtError (status));
1069  exit (status);
1070  }
1071 
1072  }
1073 #endif
1074 
1075 #define ADD_TRACE_INFO 1
1076 #ifdef ADD_TRACE_INFO
1077  {
1078  struct X400TraceInfo *info1; /*Will contain all trace information */
1079  struct X400TraceInfo *info2; /*Will only contain mandatory trace information*/
1080 
1081  status = X400mtTraceInfoNew(mp,&info1,X400_TRACE_INFO);
1082  if (status !=X400_E_NOERROR) {
1083  fprintf(stderr,"Failed to allocate new trace info object \n");
1084  exit(status);
1085  }
1086 
1087 
1088  status = X400TraceInfoAddStrParam (info1,
1090  "/PRMD=wibble/ADMD=TestADMD/C=GB/",
1091  -1);
1092  if (status !=X400_E_NOERROR) {
1093  fprintf(stderr,
1094  "Failed to add X400_S_GLOBAL_DOMAIN_ID to trace info\n");
1095  exit(status);
1096  }
1097 
1098  status = X400TraceInfoAddStrParam (info1,
1100  "071121125704Z",
1101  -1);
1102  if (status !=X400_E_NOERROR) {
1103  fprintf(stderr,
1104  "Failed to add X400_S_DSI_ARRIVAL_TIME to trace info\n");
1105  exit(status);
1106  }
1107 
1108  /*Add optional*/
1109  status = X400TraceInfoAddStrParam (info1,
1111  "/PRMD=atmpdom/ADMD=TestADMD/C=GB/",
1112  -1);
1113  if (status !=X400_E_NOERROR) {
1114  fprintf(stderr,
1115  "Failed to add X400_S_DSI_ATTEMPTED_DOMAIN to trace info\n");
1116  exit(status);
1117  }
1118 
1119 
1120  /*Add optional*/
1121  status = X400TraceInfoAddStrParam (info1,
1123  "071122125704Z",
1124  -1);
1125  if (status !=X400_E_NOERROR) {
1126  fprintf(stderr,
1127  "Failed to add X400_S_DSI_AA_DEF_TIME to trace info\n");
1128  exit(status);
1129  }
1130 
1131  /* Add optional*/
1132  status = X400TraceInfoAddStrParam (info1,
1134  "ia5-text",
1135  -1);
1136  if (status !=X400_E_NOERROR) {
1137  fprintf(stderr,
1138  "Failed to add X400_S_DSI_AA_CEIT to trace info\n");
1139  exit(status);
1140  }
1141 
1142  status = X400TraceInfoAddIntParam(info1,
1144  1);
1145  if (status !=X400_E_NOERROR) {
1146  fprintf(stderr,
1147  "Failed to add X400_N_DSI_ROUTING_ACTION to trace info\n");
1148  exit(status);
1149  }
1150 
1151  status = X400TraceInfoAddIntParam(info1,
1153  1);
1154  if (status !=X400_E_NOERROR) {
1155  fprintf(stderr,
1156  "Failed to add X400_N_DSI_AA_REDIRECTED to trace info\n");
1157  exit(status);
1158  }
1159 
1160  status = X400TraceInfoAddIntParam(info1,
1162  1);
1163  if (status !=X400_E_NOERROR) {
1164  fprintf(stderr,
1165  "Failed to add X400_N_DSI_AA_DLOPERATION to trace info\n");
1166  exit(status);
1167  }
1168 
1169  /* Trace 2 */
1170 
1171  status = X400mtTraceInfoNew(mp,&info2,X400_TRACE_INFO);
1172  if (status !=X400_E_NOERROR) {
1173  fprintf(stderr,"Failed to allocate new trace info object \n");
1174  exit(status);
1175  }
1176 
1177 
1178  status = X400TraceInfoAddStrParam (info2,
1180  "/PRMD=fluffy/ADMD=TestADMD/C=GB/",
1181  -1);
1182  if (status !=X400_E_NOERROR) {
1183  fprintf(stderr,
1184  "Failed to add X400_S_GLOBAL_DOMAIN_ID to trace info\n");
1185  exit(status);
1186  }
1187 
1188  status = X400TraceInfoAddStrParam (info2,
1190  "071121125704Z",
1191  -1);
1192  if (status !=X400_E_NOERROR) {
1193  fprintf(stderr,
1194  "Failed to add X400_S_DSI_ARRIVAL_TIME to trace info\n");
1195  exit(status);
1196  }
1197 
1198  status = X400TraceInfoAddIntParam(info2,
1200  1);
1201  if (status !=X400_E_NOERROR) {
1202  fprintf(stderr,
1203  "Failed to add X400_N_DSI_AA_REDIRECTED to trace info\n");
1204  exit(status);
1205  }
1206 
1207  status = X400TraceInfoAddIntParam(info2,
1209  1);
1210  if (status !=X400_E_NOERROR) {
1211  fprintf(stderr,
1212  "Failed to add X400_N_DSI_AA_DLOPERATION to trace info\n");
1213  exit(status);
1214  }
1215 
1216 
1217  }
1218 #endif
1219 
1220 #define USE_INTERNAL_TRACE_INFO 1
1221 #ifdef USE_INTERNAL_TRACE_INFO
1222 {
1223  struct X400InternalTraceInfo *int_info1;
1224 
1225  status = X400mtInternalTraceInfoNew(mp,&int_info1);
1226  if (status !=X400_E_NOERROR) {
1227  fprintf(stderr,"Failed to allocate new trace info object \n");
1228  exit(status);
1229  }
1230 
1231  /*GDI*/
1232  status = X400InternalTraceInfoAddStrParam (int_info1,
1234  "/PRMD=intprmd/ADMD=TestADMD/C=GB/",
1235  -1);
1236  if (status !=X400_E_NOERROR) {
1237  fprintf(stderr,
1238  "Failed to add X400_S_GLOBAL_DOMAIN_ID to trace info\n");
1239  exit(status);
1240  }
1241 
1242  /*MTA Name*/
1243  status = X400InternalTraceInfoAddStrParam (int_info1,
1245  "MTA test MTA1",
1246  -1);
1247  if (status !=X400_E_NOERROR) {
1248  fprintf(stderr,
1249  "Failed to add X400_S_MTA_NAME to trace info\n");
1250  exit(status);
1251  }
1252 
1253  /*MTA Supplied info*/
1254 
1255  status = X400InternalTraceInfoAddStrParam (int_info1,
1257  "081121125704Z",
1258  -1);
1259  if (status !=X400_E_NOERROR) {
1260  fprintf(stderr,
1261  "Failed to add X400_S_MTA_SI_TIME to trace info\n");
1262  exit(status);
1263  }
1264 
1265  /*Routing Action could be X400_MTA_SI_ROUTING_ACTION_RELAYED or
1266  * X400_MTA_SI_ROUTING_ACTION_REROUTED*/
1267  status = X400InternalTraceInfoAddIntParam(int_info1,
1270  if (status !=X400_E_NOERROR) {
1271  fprintf(stderr,
1272  "Failed to add X400_N_MTA_SI_ROUTING_ACTION to trace info\n");
1273  exit(status);
1274  }
1275 
1276 
1277  status = X400InternalTraceInfoAddStrParam (int_info1,
1279  "Attempted MTA name 1",
1280  -1);
1281  if (status !=X400_E_NOERROR) {
1282  fprintf(stderr,
1283  "Failed to add X400_S_MTA_SI_ATTEMPTED_MTA to trace info\n");
1284  exit(status);
1285  }
1286 
1287  /*
1288  You can either set the Attempted MTA or the Attempted Domain, but not
1289  both*/
1290  /*
1291  status = X400InternalTraceInfoAddStrParam (int_info1,
1292  X400_S_MTA_SI_ATTEMPTED_DOMAIN,
1293  "/PRMD=int_attmped_prmd/ADMD=TestADMD/C=GB/",
1294  -1);
1295  if (status !=X400_E_NOERROR) {
1296  fprintf(stderr,
1297  "Failed to add X400_S_MTA_SI_ATTEMPTED_DOMAIN to trace info\n");
1298  exit(status);
1299  }
1300 
1301  */
1302  status = X400InternalTraceInfoAddStrParam (int_info1,
1304  "081121125714Z",
1305  -1);
1306  if (status !=X400_E_NOERROR) {
1307  fprintf(stderr,
1308  "Failed to add X400_S_MTA_SI_DEFERRED_TIME to trace info\n");
1309  exit(status);
1310  }
1311 
1312  status = X400InternalTraceInfoAddStrParam (int_info1,
1314  "ia5-text",
1315  -1);
1316  if (status !=X400_E_NOERROR) {
1317  fprintf(stderr,
1318  "Failed to add X400_S_MTA_SI_DEFERRED_TIME to trace info\n");
1319  exit(status);
1320  }
1321 
1322  status = X400InternalTraceInfoAddIntParam(int_info1,
1325 
1326  if (status !=X400_E_NOERROR) {
1327  fprintf(stderr,
1328  "Failed to add X400_N_MTA_SI_OTHER_ACTIONS to trace info\n");
1329  exit(status);
1330  }
1331 
1332  status = X400InternalTraceInfoAddIntParam(int_info1,
1335 
1336  if (status !=X400_E_NOERROR) {
1337  fprintf(stderr,
1338  "Failed to add X400_N_MTA_SI_OTHER_ACTIONS to trace info\n");
1339  exit(status);
1340  }
1341 
1342 
1343 
1344 }
1345 #endif
1346 
1347  /* X400_N_CONTENT_LENGTH is probe only */
1348 
1349  /* Priority: 0 - normal, 1 - non-urgent, 2 - urgent */
1350  status = X400mtMsgAddIntParam (mp, X400_N_PRIORITY, def_priority);
1351  if ( status != X400_E_NOERROR ) return (status);
1352 
1353  /* Disclosure of recipients: 0 - no, 1 - yes */
1354  status = X400mtMsgAddIntParam (mp, X400_N_DISCLOSURE, 1);
1355  if ( status != X400_E_NOERROR ) return (status);
1356 
1357  /* Implicit conversion prohibited: 0 - no, 1 - yes */
1359  if ( status != X400_E_NOERROR ) return (status);
1360 
1361  /* Alternate recipient allowed: 0 - no, 1 - yes */
1363  if ( status != X400_E_NOERROR ) return (status);
1364 
1365  /* Content return request: 0 - no, 1 - yes */
1367  if ( status != X400_E_NOERROR ) return (status);
1368 
1369  /* Recipient reassignment prohibited: 0 - no, 1 - yes */
1371  if ( status != X400_E_NOERROR ) return (status);
1372 
1373  /* Distribution List expansion prohibited: 0 - no, 1 - yes */
1374  status = X400mtMsgAddIntParam (mp, X400_N_DL_EXPANSION_PROHIBITED, def_bool);
1375  if ( status != X400_E_NOERROR ) return (status);
1376 
1377  /* Conversion with loss prohibited: 0 - no, 1 - yes */
1379  if ( status != X400_E_NOERROR ) return (status);
1380 
1381  /* string params */
1382 
1383  /* Message Identifier. In RFC 2156 String form */
1384  status = X400mtMsgAddStrParam (mp, X400_S_MESSAGE_IDENTIFIER, msg_id, -1);
1385  if ( status != X400_E_NOERROR ) return (status);
1386 
1387  /* Content Identifier */
1388  status = X400mtMsgAddStrParam (mp, X400_S_CONTENT_IDENTIFIER, content_id, -1);
1389  if ( status != X400_E_NOERROR ) return (status);
1390 
1391  /*
1392  * X400_S_ORIGINAL_ENCODED_INFORMATION_TYPES
1393  * X400_S_MESSAGE_SUBMISSION_TIME
1394  * X400_S_MESSAGE_DELIVERY_TIME
1395  * are read only, so don't add them
1396  */
1397  {
1398  char *latest_time = set_latest_del_time();
1399  /* Latest Delivery Time: UTCTime format YYMMDDHHMMSS<zone> */
1400  status = X400mtMsgAddStrParam (mp, X400_S_LATEST_DELIVERY_TIME, latest_time, -1);
1401  free(latest_time);
1402  if ( status != X400_E_NOERROR ) return (status);
1403 
1404  }
1405 
1406  /* Originator Return Address (X.400 String format) */
1408  orig_ret_addr, -1);
1409  if ( status != X400_E_NOERROR ) return (status);
1410 
1411  /* Content Correlator */
1412 #define CC_IA5TEXT
1413 #ifdef CC_IA5TEXT
1415  "ABCDEFGH", -1);
1416  if ( status != X400_E_NOERROR ) return (status);
1417 #else
1419  corr_octet, 3);
1420  if ( status != X400_E_NOERROR ) return (status);
1421 #endif
1422 
1423 
1424  /* all OK */
1425  return X400_E_NOERROR;
1426 }
1427 
1428 
1429 static int build_content(
1430  struct X400mtMessage *mp
1431 )
1432 {
1433  int status;
1434 #ifdef USE_RAW_CONTENT
1435 #ifdef USE_STRING
1436  int fd;
1437  char buf[10 * 1024];
1438  int len;
1439 
1440  fd = open("./p22", O_RDONLY);
1441  if (fd == -1) {
1442  printf("Failed to open p22 file in cwd");
1443  return X400_E_SYSERROR;
1444  }
1445 
1446  len = read(fd, buf, 10 * 1024);
1447  close(fd);
1448 
1449  if (len == 10 * 1024) {
1450  printf("p22 file too long to read");
1451  return X400_E_SYSERROR;
1452  }
1453 
1454  status = X400mtMsgAddStrParam (mp, X400_S_CONTENT_STRING, buf , len);
1455  if ( status != X400_E_NOERROR ) return (status);
1456 #else
1457  status = X400mtMsgAddStrParam (mp, X400_S_CONTENT_FILENAME, "./p22", 5);
1458  if ( status != X400_E_NOERROR ) return (status);
1459 #endif
1460 #else
1461  /* content string params */
1462  status = X400mtMsgAddStrParam (mp, X400_S_IPM_IDENTIFIER, ipm_id, -1);
1463  if ( status != X400_E_NOERROR ) return (status);
1464 
1465  status = X400mtMsgAddStrParam (mp, X400_S_SUBJECT, subject, -1);
1466  if ( status != X400_E_NOERROR ) return (status);
1467 
1468  status = X400mtMsgAddStrParam (mp, X400_S_REPLIED_TO_IDENTIFIER, ipm_rep_id, -1);
1469  if ( status != X400_E_NOERROR ) return (status);
1470 
1471  status = X400mtMsgAddStrParam (mp, X400_S_OBSOLETED_IPMS, ipm_obs_id, -1);
1472  if ( status != X400_E_NOERROR ) return (status);
1473 
1474  status = X400mtMsgAddStrParam (mp, X400_S_RELATED_IPMS, ipm_rel_id, -1);
1475  if ( status != X400_E_NOERROR ) return (status);
1476 
1477  status = X400mtMsgAddStrParam (mp, X400_S_EXPIRY_TIME, def_utc, -1);
1478  if ( status != X400_E_NOERROR ) return (status);
1479 
1480  status = X400mtMsgAddStrParam (mp, X400_S_REPLY_TIME, def_utc, -1);
1481  if ( status != X400_E_NOERROR ) return (status);
1482 
1483  status = X400mtMsgAddStrParam (mp, X400_S_PRECEDENCE_POLICY_ID, "1.3.27.8.0.14", -1);
1484  if ( status != X400_E_NOERROR ) return (status);
1485 
1486 #ifdef X400_1999_SUPPORTED
1487  /* we don't support these yet */
1488  status = X400mtMsgAddStrParam (mp, X400_S_AUTHORIZATION_TIME, def_utc, -1);
1489  if ( status != X400_E_NOERROR ) return (status);
1490 
1491  status = X400mtMsgAddStrParam (mp, X400_S_ORIGINATORS_REFERENCE, orig_ref, -1);
1492  if ( status != X400_E_NOERROR ) return (status);
1493 #endif
1494 
1495  /* content int params */
1496  status = X400mtMsgAddIntParam (mp, X400_N_IMPORTANCE, importance);
1497  if ( status != X400_E_NOERROR ) return (status);
1498 
1499  status = X400mtMsgAddIntParam (mp, X400_N_SENSITIVITY, sensitivity);
1500  if ( status != X400_E_NOERROR ) return (status);
1501 
1502  status = X400mtMsgAddIntParam (mp, X400_N_AUTOFORWARDED, autoforwarded);
1503  if ( status != X400_E_NOERROR ) return (status);
1504 
1505  /* now an IA5 body part */
1506  status = X400mtMsgAddStrParam (mp, X400_T_IA5TEXT, text, -1);
1507  if ( status != X400_E_NOERROR ) return (status);
1508 
1509  /* now a binary body part */
1510  status = add_binary_bp(mp);
1511  if ( status != X400_E_NOERROR ) return (status);
1512 
1513 
1514 #ifdef ADD_FWD_BODYPART
1515  /* Now add a forwarded bodypart (So envelope + message)*/
1516  status = add_fwd_bodypart(mp);
1517  if ( status != X400_E_NOERROR ) return (status);
1518 
1519  /* Now add a forwarded content bodypart (so just the message content)
1520  * This is specified within X.420
1521  * */
1522  status = add_fwd_content_bodypart(mp);
1523  if ( status != X400_E_NOERROR ) return (status);
1524 
1525 #endif
1526 
1527 #endif
1528 
1529 #ifdef USE_P772_EXTS
1530  status = add_exempt_address(mp);
1531  if ( status != X400_E_NOERROR ) exit (status);
1532 
1533  /* Add extended Auth Info */
1535  def_utc, -1);
1536  if ( status != X400_E_NOERROR ) return (status);
1537 
1538  /* Add Message Coderess */
1539  status = X400mtMsgAddIntParam (mp, X400_N_EXT_CODRESS, 0);
1540  if ( status != X400_E_NOERROR ) return (status);
1541 
1542  /* Add P772 Message Type "type" field */
1543  status = X400mtMsgAddIntParam (mp, X400_N_EXT_MSG_TYPE, 0);
1544  if ( status != X400_E_NOERROR ) return (status);
1545 
1546  /* Add P772 MessageType "identifier" field*/
1548  def_msgid, -1);
1549  if ( status != X400_E_NOERROR ) return (status);
1550 
1551  /* Add Primary Precedence */
1552  status = X400mtMsgAddIntParam (mp, X400_N_EXT_PRIM_PREC, 5);
1553  if ( status != X400_E_NOERROR ) return (status);
1554 
1555  /* Add Copy Precedence */
1556  status = X400mtMsgAddIntParam (mp, X400_N_EXT_COPY_PREC, 4);
1557  if ( status != X400_E_NOERROR ) return (status);
1558 
1559  /* Add Address List Indicator */
1560  status = add_address_list_indicator(mp);
1561  if ( status != X400_E_NOERROR ) exit (status);
1562 
1563  /* Add Handling instructions */
1564  status = add_handling_instructions(mp);
1565  if ( status != X400_E_NOERROR ) exit (status);
1566 
1567  /* Add Message instructions */
1568  status = add_message_instructions(mp);
1569  if ( status != X400_E_NOERROR ) exit (status);
1570 
1571  /* Add Distribution codes SIC */
1572  status = add_dist_codes_sic(mp);
1573  if ( status != X400_E_NOERROR ) exit (status);
1574 
1575  /* Add Originator Ref */
1576  status = X400mtMsgAddStrParam (mp,X400_S_ORIG_REF,"orig_ref", -1);
1577  if ( status != X400_E_NOERROR ) exit (status);
1578 
1579  /* Add Originator PLAD */
1580  status = X400mtMsgAddStrParam (mp,X400_S_ORIG_PLAD,"orig_plad", -1);
1581  if ( status != X400_E_NOERROR ) exit (status);
1582 
1583  /* Add Other Recipient Indicator */
1584  status = add_other_recipient_indicator(mp);
1585  if ( status != X400_E_NOERROR ) exit (status);
1586 
1587  /* Add ACP127 Message identifier */
1588  status = X400mtMsgAddStrParam (mp,X400_S_ACP127_MSG_ID,"ACP127 msg id", -1);
1589  if ( status != X400_E_NOERROR ) exit (status);
1590 
1591  /* Add Pilot Forwarding information */
1592  {
1593  /* This is treated a a binary blob.
1594  * You need to pass in the correct BER encoded series of bytes.
1595  *
1596  */
1597  int buf_len = 0;
1598  char *pilot_ber = NULL;
1599 
1600  if (load_ber("pilot_fwd_info.ber",&pilot_ber,&buf_len) == 0) {
1601  printf("Adding pilot forwarding info\n");
1603  pilot_ber,buf_len);
1604  free(pilot_ber);
1605  if ( status != X400_E_NOERROR ) exit (status);
1606  } else {
1607  printf("unable to add pilot forwarding info\n");
1608  free(pilot_ber);
1609  }
1610 
1611  }
1612 
1613 
1614 
1615 
1616 
1617 
1618  /* Add Information Security Label. (This is the P772 / STANAG 4406 A1.16)
1619  * */
1620  {
1621  /* This is treated a a binary blob.
1622  * You need to pass in the correct BER encoded series of bytes.
1623  */
1624  int buf_len = 0;
1625  char *sec_label_ber = NULL;
1626 
1627  if (load_ber("info_sec_label.ber",&sec_label_ber,&buf_len) == 0) {
1628  printf("Adding information security label\n");
1630  sec_label_ber,buf_len);
1631  free(sec_label_ber);
1632  if ( status != X400_E_NOERROR ) exit (status);
1633  } else {
1634  printf("unable to add information security labels\n");
1635  free(sec_label_ber);
1636  }
1637 
1638  }
1639 
1640 
1641  /* Add P772 ADatP3 object */
1642  {
1643  struct X400Bodypart *ADatP3 = NULL;
1644 
1645  status = X400BodypartNew(X400_T_ADATP3,&ADatP3);
1646  if (status != X400_E_NOERROR) return status;
1647 
1648  status = X400mtMsgAddBodypart(mp,ADatP3);
1649  if (status != X400_E_NOERROR) return status;
1650 
1651  status = X400BodypartAddIntParam(ADatP3,X400_N_ADATP3_PARM,1);
1652  if (status != X400_E_NOERROR) return status;
1653 
1654  status = X400BodypartAddIntParam(ADatP3,X400_N_ADATP3_CHOICE,0);
1655  if (status != X400_E_NOERROR) return status;
1656 
1658  "The first ADatP3 Data value",
1659  -1);
1660  if (status != X400_E_NOERROR) return status;
1661 
1662  }
1663 
1664  /* Add P772 ADatP3 object with a sequence of IA5Strings */
1665  {
1666  struct X400Bodypart *ADatP3 = NULL;
1667 
1668  status = X400BodypartNew(X400_T_ADATP3,&ADatP3);
1669  if (status != X400_E_NOERROR) return status;
1670 
1671  status = X400mtMsgAddBodypart(mp,ADatP3);
1672  if (status != X400_E_NOERROR) return status;
1673 
1674  status = X400BodypartAddIntParam(ADatP3,X400_N_ADATP3_PARM,2);
1675  if (status != X400_E_NOERROR) return status;
1676 
1677  status = X400BodypartAddIntParam(ADatP3,X400_N_ADATP3_CHOICE,1);
1678  if (status != X400_E_NOERROR) return status;
1679 
1681  "The second ADatP3 Data value\r\n"
1682  "The third ADatP3 Data value\r\n"
1683  "The fourth ADatP3 Data value\r\n",
1684  -1);
1685  if (status != X400_E_NOERROR) return status;
1686  }
1687 
1688  /* Add new P772 Corrections bodypart */
1689 
1690  {
1691  struct X400Bodypart *corrections = NULL;
1692 
1693  status = X400BodypartNew(X400_T_CORRECTIONS,&corrections);
1694  if (status != X400_E_NOERROR) return status;
1695 
1696  status = X400mtMsgAddBodypart(mp,corrections);
1697  if (status != X400_E_NOERROR) return status;
1698 
1699  status = X400BodypartAddIntParam(corrections,X400_N_CORREC_PARM,1);
1700  if (status != X400_E_NOERROR) return status;
1701 
1702  status = X400BodypartAddStrParam(corrections,
1704  "A simple P772 correction",
1705  -1);
1706  if (status != X400_E_NOERROR) return status;
1707 
1708  }
1709 
1710  /* Add new ACP127Data bodypart */
1711  {
1712  struct X400Bodypart *acp127data = NULL;
1713 
1714  status = X400BodypartNew(X400_T_ACP127DATA,&acp127data);
1715  if (status != X400_E_NOERROR) return status;
1716 
1717  status = X400mtMsgAddBodypart(mp,acp127data);
1718  if (status != X400_E_NOERROR) return status;
1719 
1720  status = X400BodypartAddIntParam(acp127data,X400_N_ACP127DATA_PARM,1);
1721  if (status != X400_E_NOERROR) return status;
1722 
1723  status = X400BodypartAddStrParam(acp127data,
1725  "A simple P772 ACP127 Data IA5Text",
1726  -1);
1727  if (status != X400_E_NOERROR) return status;
1728 
1729  }
1730 
1731 #ifdef ADD_FWD_BODYPART
1732  /* Add MM Message bodypart */
1733  {
1734  struct X400Message *msg = NULL;
1735 
1736  /* We now need to add a message envelope, and the message body
1737  * to do this, we create a X400Message, and add that as the bodypart
1738  */
1739 
1740  status = X400MsgNew (X400_MSG_MESSAGE,&msg);
1741  if ( status != X400_E_NOERROR ) return (status);
1742 
1743  status = create_fw_message(msg);
1744  if ( status != X400_E_NOERROR ) return (status);
1745 
1747  def_ext_content_type, (size_t)-1);
1748  if ( status != X400_E_NOERROR ) return (status);
1749 
1750 
1751  status = X400mtMsgAddMessageBodyWType (mp,msg,X400_T_MM);
1752  if ( status != X400_E_NOERROR ) return (status);
1753  }
1754 
1755  /* Add MM Forwarded Encrypted bodypart */
1756  {
1757  char *encrypted_data = NULL;
1758  int encrypted_data_len;
1759  struct X400Message *msg = NULL;
1760 
1761  /* Slightly confusing name here.
1762  * Since encrypted data just looks like a bunch of random bits,
1763  * then for simplicity that's what we are really using.
1764  * (It's not actually ber encoded.)
1765  */
1766  if (load_ber("pilot_fwd_info.ber",&encrypted_data,&encrypted_data_len)
1767  == 1) {
1768  fprintf(stderr,"Failed to load Fwd Enc data\n");
1769  free(encrypted_data);
1770  } else {
1771 
1772  /* This is similar to the Forwarded MM message bodypart above
1773  * A new X400Message object is used to manipulate envelope
1774  * information. However for the data side of things,
1775  * an octet string is used.
1776  */
1777 
1778  status = X400MsgNew (X400_MSG_MESSAGE,&msg);
1779  if ( status != X400_E_NOERROR ) {
1780  free(encrypted_data);
1781  return (status);
1782  }
1783 
1784  /* create_fw_message
1785  * Adds envelope and content information to the message object.
1786  * We will ignore the content information, and rely on the
1787  * contents of X400_S_ENCRYPTED_DATA
1788  */
1789  status = create_fw_message(msg);
1790  if ( status != X400_E_NOERROR ) {
1791  free(encrypted_data);
1792  return (status);
1793  }
1794 
1795  /* NB create_fw_message sets the X400_CONTENT_TYPE to 2
1796  * IE interpersonal-messaging-1984
1797  * It's possible to set this to 1 which then means the content
1798  * type is externally defined
1799  */
1800 
1802  def_ext_content_type, (size_t)-1);
1803  if ( status != X400_E_NOERROR ) {
1804  free(encrypted_data);
1805  return (status);
1806  }
1807 
1808 
1810  encrypted_data, encrypted_data_len);
1811  free(encrypted_data);
1812  if ( status != X400_E_NOERROR ) return (status);
1813 
1814  status = X400mtMsgAddMessageBodyWType (mp,msg,X400_T_FWDENC);
1815  if ( status != X400_E_NOERROR ) return (status);
1816  }
1817  }
1818 
1819 
1820 #endif
1821 
1822 #endif
1823 
1824  /* Add originators certificate */
1825  {
1826  /* This is treated a a binary blob.
1827  * You need to pass in the correct BER encoded series of bytes.
1828  *
1829  */
1830  int buf_len = 0;
1831  char *cert_ber = NULL;
1832 
1833  if (load_ber("1137492922.p12",&cert_ber,&buf_len) == 0) {
1834  printf("Adding sample originator cert\n");
1836  cert_ber,buf_len);
1837  free(cert_ber);
1838  if ( status != X400_E_NOERROR ) exit (status);
1839  } else {
1840  printf("unable to add originator certificate\n");
1841  free(cert_ber);
1842  }
1843 
1844  }
1845 
1846  /* Add MOAC */
1847  {
1848  /* This is treated a a binary blob.
1849  * You need to pass in the correct BER encoded series of bytes.
1850  */
1851  int buf_len = 0;
1852  char *moac_ber = NULL;
1853 
1854  if (load_ber("MOAC.ber",&moac_ber,&buf_len) == 0) {
1855  printf("Adding MOAC\n");
1856  status = X400mtMsgAddStrParam (mp,X400_S_MOAC,
1857  moac_ber,buf_len);
1858  free(moac_ber);
1859  if ( status != X400_E_NOERROR ) exit (status);
1860  } else {
1861  printf("unable to add originator certificate\n");
1862  free(moac_ber);
1863  }
1864 
1865  }
1866 
1867 
1868  return X400_E_NOERROR;
1869 }
1870 
1871 
1872 static int add_binary_bp(
1873  struct X400mtMessage *mp
1874 )
1875 {
1876  FILE *fp = NULL;
1877  int fs=0;
1878  char *binary_data;
1879  int status;
1880 
1881  /* or a Binary body part using the bodypart func */
1882  if (filename_to_send != NULL) {
1883  fp = fopen(filename_to_send, "rb");
1884  if (fp == (FILE *)NULL) {
1885  printf("Cannot open binary file\n");
1886  return (X400_E_SYSERROR);
1887  }
1888  binary_data = (char *) malloc(bin_bp_size);
1889  if ( binary_data == NULL )
1890  return X400_E_NOMEMORY;
1891  if ((fs = fread (binary_data, sizeof(char),
1892  bin_bp_size/sizeof(char), fp) ) == -1) {
1893  printf("Cannot read from binary file\n");
1894  free (binary_data);
1895  fclose(fp);
1896  return (X400_E_SYSERROR);
1897  }
1898  fclose(fp);
1899  if (fs < bin_bp_size) {
1900  printf("Cannot read %d bytes from binary file (got %d)\n",
1901  bin_bp_size, fs);
1902  free (binary_data);
1903  return (X400_E_SYSERROR);
1904  }
1905 
1906  status = X400mtMsgAddAttachment (mp, X400_T_BINARY, binary_data, fs);
1907  free (binary_data);
1908  if ( status != X400_E_NOERROR ) {
1909  printf("failed to add X400_T_BINARY BP\n");
1910  return (status);
1911  }
1912  } else {
1913  printf("no binary file set - not sending X400_T_BINARY\n");
1914  }
1915  return X400_E_NOERROR;
1916 }
1917 
1918 static int add_env_recip_info(
1919  struct X400Recipient *rp
1920 )
1921 {
1922  int status;
1923 
1924  /* add attributes to recipient in envelope */
1926  if ( status != X400_E_NOERROR ) return (status);
1927 
1928  /* NDR only = 1 */
1930  if ( status != X400_E_NOERROR ) return (status);
1931 
1932  /* none = 0 */
1934  if ( status != X400_E_NOERROR ) return (status);
1935 
1937  rno++;
1938  if ( status != X400_E_NOERROR ) return (status);
1939 
1940  status = X400mtRecipAddStrParam (rp,
1942  if ( status != X400_E_NOERROR ) return (status);
1943 
1944  status = X400mtRecipAddStrParam (rp,
1946  if ( status != X400_E_NOERROR ) return (status);
1947 
1948  return X400_E_NOERROR;
1949 }
1950 
1951 #ifdef add_multi_recips
1952 static int add_content_recip_info(
1953  struct X400Recipient *rp,
1954  const char *free_form_name
1955 )
1956 {
1957  int status;
1958 
1959  /* add attributes to recipient in content */
1961  if ( status != X400_E_NOERROR ) return (status);
1962 
1964  if ( status != X400_E_NOERROR ) return (status);
1965 
1966  status = X400mtRecipAddStrParam (rp,
1967  X400_S_FREE_FORM_NAME, free_form_name, -1);
1968  if ( status != X400_E_NOERROR ) return (status);
1969 
1970  return X400_E_NOERROR;
1971 }
1972 #endif
1973 
1974 static void usage(void) {
1975  printf("usage: %s\n", optstr);
1976  printf("\t where:\n");
1977  printf("\t -u : Don't prompt to override defaults \n");
1978  printf("\t -G : Originator \n");
1979  printf("\t -O : Originator Return Address \n");
1980  printf("\t -g : Recipient\n");
1981  printf("\t -c : X.400 passive channel\n");
1982  printf("\t -l : Logline\n");
1983  printf("\t -R : Reports (0 - never, 1 - always, 2 - always NDR \n");
1984  printf("\t -y : Priority (0 - normal, 1 - non-urgent, 2 - urgent \n");
1985  printf("\t -C : Content Type (2/22/772/OID) \n");
1986  printf("\t -i : Implicit conversion prohibited = TRUE \n");
1987  printf("\t -a : Alternate Recipient Prohibited = TRUE \n");
1988  printf("\t -q : Content Return Request = TRUE \n");
1989  printf("\t -s : Disclosure of Recipient = FALSE \n");
1990  printf("\t -A : Recipient Reassignment Prohibited = FALSE \n");
1991  printf("\t -v : Conversion with Loss Prohibited = FALSE \n");
1992  printf("\t -f : Filename to transfer as binary bp\n");
1993  printf("\t -X : Number of messages to send\n");
1994  printf("\t -S : Size of binary attachment (requires -f)\n");
1995  return;
1996 }
1997 
1998 
1999 char *set_latest_del_time(
2000  void
2001 )
2002 {
2003  static char latest_del_time[BUFSIZ];
2004  time_t now_secs;
2005 
2006  time(&now_secs);
2007  now_secs += 60*60*24*2; /* 2 days in the future */
2008 
2009  strftime(latest_del_time,
2010  BUFSIZ,
2011  "%y%m%d%H%M%SZ",
2012  gmtime(&now_secs));
2013  return strdup(latest_del_time);
2014 }
2015 
2016 
2017 /* This function is used to load up pre-created BER files
2018  * E.G P772 Pilot forwarding information*/
2019 static int load_ber(
2020  char *filename,
2021  char **output_buffer,
2022  int *buf_len
2023 )
2024 {
2025  FILE *fd = NULL;
2026 
2027 
2028  struct stat stat_info;
2029 
2030  if (stat(filename, &stat_info)!=0) {
2031  fprintf(stderr,"Failed to stat %s : %s\n",
2032  filename,strerror(errno));
2033  return 1;
2034  }
2035 
2036  *output_buffer = (char*) malloc (sizeof(char) * stat_info.st_size);
2037  /* Read in the security label XML file */
2038  fd = fopen(filename,"r");
2039  if(fd == NULL) {
2040  fprintf(stderr,"Failed to open %s : %s\n",
2041  filename,strerror(errno));
2042  return 1;
2043  }
2044 
2045  fread(*output_buffer,stat_info.st_size,1,fd);
2046 
2047  fclose(fd);
2048  *buf_len = stat_info.st_size;
2049 
2050  return 0;
2051 }
2052 
2053 #ifdef ADD_FWD_BODYPART
2054 static int add_fwd_bodypart(
2055  struct X400mtMessage *mp
2056 )
2057 {
2058  int status;
2059  struct X400Message *mbp;
2060  /* Create an X.400 Message */
2061  status = X400MsgNew (X400_MSG_MESSAGE,&mbp);
2062  if (status != X400_E_NOERROR) {
2063  fprintf(stderr,"add_fwd_bodypart: %s\n",X400mtError(status));
2064  return status;
2065  }
2066 
2067  status = create_fw_message(mbp);
2068  if (status != X400_E_NOERROR) {
2069  fprintf(stderr,"failed to create fwd message\n");
2070  return status;
2071  }
2072 
2073  /* Append that to the extisting message */
2074  return X400mtMsgAddMessageBody (mp,mbp);
2075 }
2076 
2077 static int build_fwd_env (
2078  struct X400Message *mp
2079 )
2080 {
2081  int status;
2082  /* Build envelope */
2083 
2084  /*
2085  * X400_S_ORIGINAL_ENCODED_INFORMATION_TYPES
2086  * X400_S_MESSAGE_SUBMISSION_TIME
2087  * X400_S_MESSAGE_DELIVERY_TIME
2088  */
2089 
2090  /* Add X400_S_ORIGINAL_ENCODED_INFORMATION_TYPES */
2091  status = X400MsgAddStrParam (mp,
2093  "ia5-text",
2094  (size_t)-1);
2095  if ( status != X400_E_NOERROR ) return (status);
2096 
2097  status = X400MsgAddStrParam (mp,
2099  "070801120000+0100",
2100  (size_t)-1);
2101  if ( status != X400_E_NOERROR ) return (status);
2102 
2103  status = X400MsgAddStrParam (mp,
2105  "070801120000+0100",
2106  (size_t)-1);
2107  if ( status != X400_E_NOERROR ) return (status);
2108 
2109  /* Add Priority */
2110  status = X400MsgAddIntParam (mp, X400_N_PRIORITY, 1);
2111  if ( status != X400_E_NOERROR ) return (status);
2112 
2113  /* Add recipient disclosure */
2114  status = X400MsgAddIntParam (mp, X400_N_DISCLOSURE, 0);
2115  if ( status != X400_E_NOERROR ) return (status);
2116 
2117  /* Add implicit conversion prohibited */
2118  status = X400MsgAddIntParam (mp,
2120  1);
2121  if ( status != X400_E_NOERROR ) return (status);
2122 
2123  /* Add alt recipient allowed */
2125  if ( status != X400_E_NOERROR ) return (status);
2126 
2127  /* Add Content return request */
2129  if ( status != X400_E_NOERROR ) return (status);
2130 
2131 
2132  /* Add Content return request */
2134  if ( status != X400_E_NOERROR ) return (status);
2135 
2136 
2137  /* Add Recipient reassignment prohibited */
2138  status = X400MsgAddIntParam (mp,
2140  if ( status != X400_E_NOERROR ) return (status);
2141 
2142  /* Add Distribution list expansion prohibited */
2144  if ( status != X400_E_NOERROR ) return (status);
2145 
2146  /* Add Conversion with loss prohibited */
2147  status = X400MsgAddIntParam (mp,
2149  1);
2150  if ( status != X400_E_NOERROR ) return (status);
2151 
2152  /* Add Message Identifier */
2153  status = X400MsgAddStrParam (mp,
2155  fwd_msg_id,
2156  (size_t)-1);
2157  if ( status != X400_E_NOERROR ) return (status);
2158 
2159  /* Add Content Identifier */
2160  status = X400MsgAddStrParam (mp,
2161  X400_S_CONTENT_IDENTIFIER, content_id, (size_t)-1);
2162  if ( status != X400_E_NOERROR ) return (status);
2163 
2164  /* Add Latest Delivery Time */
2165  {
2166  char *latest_time = set_latest_del_time();
2167  /* Latest Delivery Time: UTCTime format YYMMDDHHMMSS<zone> */
2168  status = X400MsgAddStrParam (mp,
2170  latest_time, (size_t)-1);
2171  free(latest_time);
2172  if ( status != X400_E_NOERROR ) return (status);
2173  }
2174  return X400_E_NOERROR;
2175 }
2176 
2177 static int build_fwd_content (
2178  struct X400Message *mp
2179 )
2180 {
2181  int status;
2182  /* Build content */
2183  /* Add IPM Identifier */
2184  status = X400MsgAddStrParam (mp, X400_S_IPM_IDENTIFIER, ipm_id, (size_t)-1);
2185  if ( status != X400_E_NOERROR ) return (status);
2186 
2187  /* Add Subject */
2188  status = X400MsgAddStrParam (mp, X400_S_SUBJECT,"Forwarded test message", (size_t)-1);
2189  if ( status != X400_E_NOERROR ) return (status);
2190 
2191  /* Add Replied to identifer */
2192  status = X400MsgAddStrParam (mp, X400_S_REPLIED_TO_IDENTIFIER, ipm_rel_id, (size_t)-1);
2193  if ( status != X400_E_NOERROR ) return (status);
2194 
2195  /* Add Obseleted IPMs */
2196  status = X400MsgAddStrParam (mp, X400_S_OBSOLETED_IPMS, ipm_obs_id, (size_t)-1);
2197  if ( status != X400_E_NOERROR ) return (status);
2198 
2199  /* Add Related IPMs */
2200  status = X400MsgAddStrParam (mp, X400_S_RELATED_IPMS, ipm_rel_id, (size_t)-1);
2201  if ( status != X400_E_NOERROR ) return (status);
2202 
2203  /* Add Expiry times */
2204  status = X400MsgAddStrParam (mp, X400_S_EXPIRY_TIME, def_utc, (size_t)-1);
2205  if ( status != X400_E_NOERROR ) return (status);
2206 
2207  /* Add Reply times */
2208  status = X400MsgAddStrParam (mp, X400_S_REPLY_TIME, def_utc, (size_t)-1);
2209  if ( status != X400_E_NOERROR ) return (status);
2210 
2211  /* Add Importance */
2212  status = X400MsgAddIntParam (mp, X400_N_IMPORTANCE, importance);
2213  if ( status != X400_E_NOERROR ) return (status);
2214 
2215  /* Add Sensitivity */
2216  status = X400MsgAddIntParam (mp, X400_N_SENSITIVITY, sensitivity);
2217  if ( status != X400_E_NOERROR ) return (status);
2218 
2219  /* Add Autoforwarded */
2220  status = X400MsgAddIntParam (mp, X400_N_AUTOFORWARDED, autoforwarded);
2221  if ( status != X400_E_NOERROR ) return (status);
2222 
2223  /* Add IA5text */
2224  status = X400MsgAddStrParam (mp, X400_T_IA5TEXT,
2225  "This is a forwarded test message", (size_t)-1);
2226  if ( status != X400_E_NOERROR ) return (status);
2227 
2228  return X400_E_NOERROR;
2229 }
2230 
2231 static int add_fwd_recip(
2232  struct X400Message *mp,
2233  const char *oraddress,
2234  int type
2235 )
2236 {
2237  struct X400Recipient *rp;
2238  int status;
2239 
2240  status = X400RecipNew (type,&rp);
2241  if (status != X400_E_NOERROR) {
2242  fprintf(stderr,"Failed to create new \n");
2243  return status;
2244  }
2245 
2246  status = X400MsgAddRecip(mp, type, rp);
2247  if (status != X400_E_NOERROR) {
2248  fprintf(stderr,"Failed to add fwd recipient\n");
2249  return status;
2250  }
2251 
2252  status = X400RecipAddStrParam (rp, X400_S_OR_ADDRESS, oraddress, -1);
2253  if ( status != X400_E_NOERROR ) return (status);
2254 
2255  status = X400RecipAddIntParam (rp, X400_N_RESPONSIBILITY, 1);
2256  if ( status != X400_E_NOERROR ) return (status);
2257 
2259  if ( status != X400_E_NOERROR ) return (status);
2260 
2261  status = X400RecipAddIntParam (rp, X400_N_REPORT_REQUEST, 0);
2262  if ( status != X400_E_NOERROR ) return (status);
2263 
2265  fwd_rno);
2266  fwd_rno++;
2267  if ( status != X400_E_NOERROR ) return (status);
2268 
2269  return X400_E_NOERROR;
2270 }
2271 
2272 static int create_fw_message(
2273  struct X400Message *mp
2274 )
2275 {
2276  int status;
2277  /* Add Originator Address */
2278  status = X400MsgAddStrParam (mp, X400_S_OR_ADDRESS, fwd_orig, (size_t)-1);
2279  if ( status != X400_E_NOERROR ) exit (status);
2280 
2281  /* Add Recipient Address */
2282  status = add_fwd_recip(mp,fwd_orig,X400_ORIGINATOR);
2283  if (status != X400_E_NOERROR) {
2284  fprintf(stderr,"Failed to added forwarded originator\n");
2285  return status;
2286  }
2287 
2288  status = add_fwd_recip(mp,fwd_recip,X400_RECIP_STANDARD);
2289  if (status != X400_E_NOERROR) {
2290  fprintf(stderr,"Failed to added forwarded originator\n");
2291  return status;
2292  }
2293 
2294  status = build_fwd_env(mp);
2295  if (status != X400_E_NOERROR) {
2296  fprintf(stderr,"Failed to build forwarded message envelope\n");
2297  return status;
2298  }
2299 
2300  status = build_fwd_content(mp);
2301  if (status != X400_E_NOERROR){
2302  fprintf(stderr,"Failed to build forwarded message content\n");
2303  return status;
2304  }
2305 
2306 
2307  /* Add external content type */
2308 
2309  return X400_E_NOERROR;
2310 }
2311 
2312 static int add_fwd_content_bodypart (
2313  struct X400mtMessage *mp
2314 )
2315 {
2316 
2317  int buf_len = 0;
2318  char *fwd_content_ber = NULL;
2319  struct X400Message *mbp;
2320  int status;
2321 
2322 /* Create an X.400 Message */
2323  status = X400MsgNew (X400_MSG_MESSAGE,&mbp);
2324  if (status != X400_E_NOERROR) {
2325  fprintf(stderr,"add_fwd_bodypart: %s\n",X400mtError(status));
2326  return status;
2327  }
2328 
2329  status = create_fw_message(mbp);
2330  if ( status != X400_E_NOERROR ) return (status);
2331 
2333  def_ext_content_type, (size_t)-1);
2334  if ( status != X400_E_NOERROR ) return (status);
2335 
2336  if (load_ber("example_fwd_content.ber",&fwd_content_ber,&buf_len) == 0) {
2337  printf("Adding forwarded content string\n");
2338 
2340  fwd_content_ber, buf_len);
2341  free(fwd_content_ber);
2342  if ( status != X400_E_NOERROR ) exit (status);
2343 
2345  if ( status != X400_E_NOERROR ) return (status);
2346  } else {
2347  printf("unable to add forwarded content info\n");
2348  free(fwd_content_ber);
2349  }
2350 
2351 
2352 
2353  return X400_E_NOERROR;
2354 }
2355 
2356 #endif
2357 
2358 
2359 
2360 static int add_dl_exempted_recip_list (
2361  struct X400mtMessage *mp
2362 )
2363 {
2364  struct X400Recipient *rp1;
2365  struct X400Recipient *rp2;
2366  struct X400Recipient *rp3;
2367  int status;
2368 
2369  status = X400mtRecipNew (mp,X400_DL_EXEMPTED_RECIP, &rp1);
2370  if ( status != X400_E_NOERROR ) return (status);
2371 
2373  "/cn=x411exempted1/PRMD=TestPRMD/"
2374  "ADMD=TestADMD/C=GB", -1);
2375  if ( status != X400_E_NOERROR ) return (status);
2376 
2377  status = X400mtRecipNew (mp,X400_DL_EXEMPTED_RECIP, &rp2);
2378  if ( status != X400_E_NOERROR ) return (status);
2379 
2381  "/cn=x411exempted2/PRMD=TestPRMD/"
2382  "ADMD=TestADMD/C=GB", -1);
2383  if ( status != X400_E_NOERROR ) return (status);
2384 
2385  status = X400mtRecipNew (mp,X400_DL_EXEMPTED_RECIP, &rp3);
2386  if ( status != X400_E_NOERROR ) return (status);
2387 
2389  "/cn=x411exempted3/PRMD=TestPRMD/"
2390  "ADMD=TestADMD/C=GB", -1);
2391  if ( status != X400_E_NOERROR ) return (status);
2392 
2393  return X400_E_NOERROR;
2394 }
#define X400_S_DIRECTORY_NAME
Definition: x400_att.h:394
#define X400_MSG_MESSAGE
Definition: x400_att.h:29
#define X400_S_EXTERNAL_CONTENT_TYPE
Definition: x400_att.h:444
#define X400_S_ORIGINATOR_REQUESTED_ALTERNATE_RECIPIENT
Definition: x400_att.h:658
#define X400_RR_ALIAS
Definition: x400_att.h:1519
#define X400_S_MTA_SI_DEFERRED_TIME
Definition: x400_att.h:1556
#define X400_N_EXT_MSG_TYPE
Definition: x400_att.h:857
#define X400_ACP127_NOTI_TYPE_POS
Definition: x400_att.h:1613
#define X400_S_ORIGINATOR_RETURN_ADDRESS
Definition: x400_att.h:464
#define X400_N_IMPLICIT_CONVERSION_PROHIBITED
Definition: x400_att.h:427
#define X400_EXEMPTED_ADDRESS
Definition: x400_att.h:329
#define X400_S_DIST_CODES_EXT_OID
Definition: x400_att.h:890
#define X400_E_SYSERROR
Definition: x400_att.h:49
#define X400_S_DLEXP_TIME
Definition: x400_att.h:476
#define X400_DL_EXEMPTED_RECIP
Definition: x400_att.h:320
#define X400_S_LOG_CONFIGURATION_FILE
Definition: x400_att.h:1080
#define X400_S_EXT_AUTH_INFO
Definition: x400_att.h:851
int X400mtMsgAddMessageBody(struct X400mtMessage *mp, struct X400Message *mbp)
#define X400_N_EXT_CODRESS
Definition: x400_att.h:854
#define X400_N_ADATP3_PARM
Definition: x400_att.h:914
int X400mtDLExpHistNew(struct X400mtMessage *mp, struct X400DLExpHist **histp)
Create a new DL Expansion History object, and associate it with the existing message.
#define X400_S_CONTENT_IDENTIFIER
Definition: x400_att.h:411
X400COMMON_CDECL int X400RediHistAddIntParam(struct X400RediHist *hist, int paramtype, int value)
Set an integer value in a Redirection History object.
X400COMMON_CDECL int X400MsgAddRecip(struct X400Message *mp, int reciptype, struct X400Recipient *recip)
Add a recipient object to the message.
int X400mtOpen(const char *credentials, struct X400mtSession **spp)
Open a session to the MTA.
#define X400_N_MTA_SI_ROUTING_ACTION
Definition: x400_att.h:1547
X400COMMON_CDECL int X400ACP127RespAddStrParam(struct X400ACP127Resp *resp, int type, const char *value, size_t length)
Add string-valued parameter to the ACP127 Notification Response object.
#define X400_N_ADATP3_CHOICE
Definition: x400_att.h:917
#define X400_S_ACP127_NOTI_RESP_RECIPIENT
Definition: x400_att.h:1635
#define X400_N_ACP127_NOTI_TYPE
Definition: x400_att.h:908
#define X400_AUTH_ORIG
Definition: x400_att.h:305
#define X400_RECIP_CC
Definition: x400_att.h:296
#define X400_ADATP3_SEP
Definition: x400_att.h:1101
#define X400_S_ORIG_CERT
Definition: x400_att.h:971
X400COMMON_CDECL int X400OtherRecipAddIntParam(struct X400OtherRecip *otherrecip, int value)
Add integer parameter to the Other Recipient Indicator object.
#define X400_N_ALI_TYPE
Definition: x400_att.h:1594
#define X400_S_DIST_CODES_SIC
Definition: x400_att.h:884
#define X400_S_MTA_SI_ATTEMPTED_MTA
Definition: x400_att.h:1550
int X400mtOtherRecipNew(struct X400mtMessage *mp, struct X400OtherRecip **otherrecip)
Create a new P772 Other Recipient object for a message object.
#define X400_N_ALI_REPLY_REQUEST
Definition: x400_att.h:1600
int X400mtMsgNew(struct X400mtSession *sp, int type, struct X400mtMessage **mpp)
Creates new message.
#define X400_N_RESPONSIBILITY
Definition: x400_att.h:639
#define X400_N_ACP127DATA_PARM
Definition: x400_att.h:938
#define X400_N_DSI_AA_DLOPERATION
Definition: x400_att.h:499
X400COMMON_CDECL int X400PSSAddStrParam(struct X400PSS *pss, const char *value, size_t length)
Add string-valued parameter to the PSS info object.
#define X400_T_ACP127DATA
Definition: x400_att.h:935
#define X400_S_ACP127_NOTI_RESP_SUPP_INFO
Definition: x400_att.h:1638
#define X400_N_DL_EXPANSION_PROHIBITED
Definition: x400_att.h:455
X400COMMON_CDECL int X400TraceInfoAddIntParam(struct X400TraceInfo *info, int paramtype, int value)
Set an integer value in a Trace Info object.
#define X400_T_FWD_CONTENT
Definition: x400_att.h:962
#define X400_S_CONTENT_CORRELATOR_IA5_STRING
Definition: x400_att.h:514
#define X400_S_FREE_FORM_NAME
Definition: x400_att.h:666
#define X400_S_DSI_ARRIVAL_TIME
Definition: x400_att.h:481
#define X400_S_ORIG_REF
Definition: x400_att.h:878
X.400 Gateway Interface.
X400COMMON_CDECL int X400ALIAddStrParam(struct X400ALI *info, int paramtype, const char *value, size_t length)
Add string-valued parameter to the ALI info object.
#define X400_S_INFO_SEC_LABEL
Definition: x400_att.h:911
#define X400_S_MTA_SI_TIME
Definition: x400_att.h:1544
#define X400_N_DSI_AA_REDIRECTED
Definition: x400_att.h:496
#define X400_N_CONVERSION_WITH_LOSS_PROHIBITED
Definition: x400_att.h:458
X400COMMON_CDECL int X400RecipAddIntParam(struct X400Recipient *rp, int paramtype, int value)
Add integer-valued parameter to the recipient.
#define X400_S_ORIGINAL_ENCODED_INFORMATION_TYPES
Definition: x400_att.h:414
int X400mtRecipNew(struct X400mtMessage *mp, int type, struct X400Recipient **rpp)
Add new recipient to a message.
#define X400_N_RECIPIENT_REASSIGNMENT_PROHIBITED
Definition: x400_att.h:452
int X400mtSetStrDefault(struct X400mtSession *sp, int paramtype, const char *value, size_t length)
Set a default string parameter value in a session.
#define X400_S_ACP127_MSG_ID
Definition: x400_att.h:902
#define X400_S_CONTENT_STRING
Definition: x400_att.h:763
#define X400_N_NOTIFICATION_REQUEST
Definition: x400_att.h:672
int X400mtMsgAddIntParam(struct X400mtMessage *mp, int paramtype, int value)
Add integer-valued parameter to the message.
#define X400_S_MESSAGE_SUBMISSION_TIME
Definition: x400_att.h:436
#define X400_S_EXPIRY_TIME
Definition: x400_att.h:733
#define X400_T_IA5TEXT
Definition: x400_att.h:795
#define X400_E_NOERROR
Definition: x400_att.h:46
X400COMMON_CDECL int X400DistFieldAddStrParam(struct X400DistField *distfield, int type, const char *value, size_t length)
Add string-valued parameter to the DistField info object.
#define X400_N_EXT_COPY_PREC
Definition: x400_att.h:863
X400COMMON_CDECL int X400ALIAddIntParam(struct X400ALI *info, int paramtype, int value)
Set an integer value in an Address List Indicator object.
#define X400_S_AUTHORIZATION_TIME
Definition: x400_att.h:752
int X400mtRecipAddStrParam(struct X400Recipient *rp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
#define X400_ORIGINATOR
Definition: x400_att.h:302
int X400mtRecipAddIntParam(struct X400Recipient *rp, int paramtype, int value)
Add integer-valued parameter to the message.
#define X400_MTA_SI_OTHER_ACTION_DLOPERATION
Definition: x400_att.h:1583
int X400mtMsgAddAttachment(struct X400mtMessage *mp, int type, const char *string, size_t length)
Add an attachment to the message.
#define X400_S_REDIRECTION_TIME
Definition: x400_att.h:508
#define X400_S_OR_ADDRESS
Definition: x400_att.h:346
#define X400_S_CONTENT_FILENAME
Definition: x400_att.h:768
#define X400_T_ADATP3
Definition: x400_att.h:923
#define X400_S_RELATED_IPMS
Definition: x400_att.h:730
#define X400_MTA_SI_RA_MTA
Definition: x400_att.h:1568
X400COMMON_CDECL int X400InternalTraceInfoAddStrParam(struct X400InternalTraceInfo *info, int paramtype, const char *value, size_t length)
Add string-valued parameter to the Internal Trace info object.
#define X400_S_MESSAGE_IDENTIFIER
Definition: x400_att.h:402
#define X400_S_ORIG_PLAD
Definition: x400_att.h:881
const char * X400mtError(int error)
Return string for error code.
#define X400_RECIP_STANDARD
Definition: x400_att.h:338
int X400mtMsgSend(struct X400mtMessage *mp)
Send message object to MTA.
#define X400_N_ALI_NOTIFICATION_REQUEST
Definition: x400_att.h:1597
#define X400_T_BINARY
Definition: x400_att.h:821
X400COMMON_CDECL int X400BodypartNew(int type, struct X400Bodypart **bpp)
Create a new body part object.
#define X400_N_DISCLOSURE
Definition: x400_att.h:424
#define X400_S_PILOT_FWD_INFO
Definition: x400_att.h:899
#define X400_S_GLOBAL_DOMAIN_ID
Definition: x400_att.h:478
#define X400_ACP127_NOTI_TYPE_NEG
Definition: x400_att.h:1610
#define X400_S_SECURITY_LABEL
Definition: x400_att.h:1310
#define X400_S_DIST_CODES_EXT_VALUE
Definition: x400_att.h:893
X400COMMON_CDECL int X400MsgNew(int type, struct X400Message **mpp)
Creates new message.
#define X400_RECIP_PRIMARY
Definition: x400_att.h:293
X400COMMON_CDECL int X400OtherRecipAddStrParam(struct X400OtherRecip *otherrecip, const char *value, size_t length)
Add string-valued parameter to the Other Recipient Indicator object.
#define X400_S_LATEST_DELIVERY_TIME
Definition: x400_att.h:461
int X400mtPSSNew(struct X400mtMessage *mp, int type, struct X400PSS **pss)
Create a new Printable String Syntax object for a message object.
X400COMMON_CDECL int X400MsgAddIntParam(struct X400Message *mp, int paramtype, int value)
Add integer-valued parameter to the message.
#define X400_S_ORIGINATOR_REQUESTED_ALTERNATE_RECIPIENT_DN
Definition: x400_att.h:662
#define X400_S_CORREC_DATA
Definition: x400_att.h:932
#define X400_N_REPORT_REQUEST
Definition: x400_att.h:650
#define X400_N_SENSITIVITY
Definition: x400_att.h:742
#define X400_T_FWDENC
Definition: x400_att.h:947
#define X400_S_ADATP3_DATA
Definition: x400_att.h:920
#define X400_S_CONTENT_CORRELATOR_OCTET_STRING
Definition: x400_att.h:517
#define X400_N_MTA_SI_OTHER_ACTIONS
Definition: x400_att.h:1562
int X400mtDistFieldNew(struct X400mtMessage *mp, struct X400DistField **distfield)
Create a new P772 Distribution Field object for a message object.
#define X400_S_IPM_IDENTIFIER
Definition: x400_att.h:698
X400COMMON_CDECL int X400ACP127RespAddIntParam(struct X400ACP127Resp *resp, int value)
Add integer parameter to the ACP127 Notification Response object.
#define X400_S_EXT_MSG_IDENTIFIER
Definition: x400_att.h:977
X400COMMON_CDECL int X400TraceInfoAddStrParam(struct X400TraceInfo *info, int paramtype, const char *value, size_t length)
Add string-valued parameter to the X400TraceInfo object.
#define X400_S_ACP127_DATA
Definition: x400_att.h:941
#define X400_N_IMPORTANCE
Definition: x400_att.h:739
int X400mtMsgAddStrParam(struct X400mtMessage *mp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
#define X400_N_PRIORITY
Definition: x400_att.h:419
#define X400_S_ACP127_NOTI_RESP_TIME
Definition: x400_att.h:1629
X400COMMON_CDECL int X400BodypartAddStrParam(struct X400Bodypart *bp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the body part.
int X400mtClose(struct X400mtSession *sp)
Close a X400 Session.
#define X400_N_REPLY_REQUESTED
Definition: x400_att.h:679
X400COMMON_CDECL int X400BodypartAddIntParam(struct X400Bodypart *bp, int paramtype, int value)
Add integer-valued parameter to the body part.
#define X400_N_ORIGINAL_RECIPIENT_NUMBER
Definition: x400_att.h:636
int X400mtTraceInfoNew(struct X400mtMessage *mp, struct X400TraceInfo **info, int type)
Create a new Trace Info object for a message object.
#define X400_S_DSI_AA_CEIT
Definition: x400_att.h:493
#define X400_T_MM
Definition: x400_att.h:944
#define X400_S_FWD_CONTENT_STRING
Definition: x400_att.h:956
int X400mtMsgAddBodypart(struct X400mtMessage *mp, struct X400Bodypart *bp)
Add a body part object to a message.
#define X400_RR_RECIP_ASSIGNED_ALT_RECIP
Definition: x400_att.h:1510
#define X400_T_CORRECTIONS
Definition: x400_att.h:926
#define X400_TRACE_INFO
Definition: x400_att.h:1313
#define X400_E_NOMEMORY
Definition: x400_att.h:52
#define X400_N_EXT_PRIM_PREC
Definition: x400_att.h:860
#define X400_S_MTA_NAME
Definition: x400_att.h:1541
X400COMMON_CDECL int X400ACP127RespNewALI(struct X400ACP127Resp *resp, struct X400ALI **ali)
Create new Address List Indicator object associated with the X400ACP127 Resp.
X400COMMON_CDECL int X400InternalTraceInfoAddIntParam(struct X400InternalTraceInfo *info, int paramtype, int value)
Set an integer value in an Internal Trace Info object.
#define X400_S_TELEPHONE_NUMBER
Definition: x400_att.h:669
#define X400_S_HANDLING_INSTRUCTIONS
Definition: x400_att.h:869
X400COMMON_CDECL int X400RecipNew(int type, struct X400Recipient **rpp)
Create a new recipient object.
#define X400_E_TEMPORARY_ERROR
Definition: x400_att.h:277
#define X400_N_ALTERNATE_RECIPIENT_ALLOWED
Definition: x400_att.h:430
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_REPLY
Definition: x400_att.h:308
#define X400_S_SUBJECT
Definition: x400_att.h:719
#define X400_ACP127_NOTI_TYPE_TRANS
Definition: x400_att.h:1616
X400COMMON_CDECL int X400RediHistNew(struct X400Recipient *recip, struct X400RediHist **hist)
Create a new Redirection History object.
X400COMMON_CDECL int X400MsgAddStrParam(struct X400Message *mp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the message.
int X400mtMsgAddMessageBodyWType(struct X400mtMessage *mp, struct X400Message *mbp, int type)
Add a message body part object to a message.
#define X400_S_DSI_ATTEMPTED_DOMAIN
Definition: x400_att.h:487
#define X400_S_PRECEDENCE_POLICY_ID
Definition: x400_att.h:758
#define X400_N_MTA_REPORT_REQUEST
Definition: x400_att.h:642
#define X400_S_MESSAGE_INSTRUCTIONS
Definition: x400_att.h:873
#define X400_S_MTA_SI_CEIT
Definition: x400_att.h:1559
#define X400_N_REDIRECTION_REASON
Definition: x400_att.h:505
int X400mtALINew(struct X400mtMessage *mp, struct X400ALI **ali)
Create a new Address List Indicator object for a message object.
int X400mtInternalTraceInfoNew(struct X400mtMessage *mp, struct X400InternalTraceInfo **info)
Create a new Internal Trace Info object for a message object.
#define X400_N_CORREC_PARM
Definition: x400_att.h:929
#define X400_S_OBSOLETED_IPMS
Definition: x400_att.h:726
#define X400_S_MOAC
Definition: x400_att.h:566
#define X400_S_DSI_AA_DEF_TIME
Definition: x400_att.h:490
#define X400_N_CONTENT_RETURN_REQUEST
Definition: x400_att.h:433
#define X400_S_REPLY_TIME
Definition: x400_att.h:736
#define X400_MTA_SI_OTHER_ACTION_REDIRECTED
Definition: x400_att.h:1580
X400COMMON_CDECL int X400RecipAddStrParam(struct X400Recipient *rp, int paramtype, const char *value, size_t length)
Add string-valued parameter to the recipient.
#define X400_S_REPLIED_TO_IDENTIFIER
Definition: x400_att.h:722
#define X400_RECIP_BCC
Definition: x400_att.h:299
#define X400_N_DSI_ROUTING_ACTION
Definition: x400_att.h:484
#define X400_S_ORIGINATORS_REFERENCE
Definition: x400_att.h:755
X400COMMON_CDECL int X400DLExpHistAddStrParam(struct X400DLExpHist *hist, int paramtype, const char *value, size_t length)
Add string-valued parameter to the X400DLExpHist object.
#define X400_S_ENCRYPTED_DATA_BYTES_ONLY
Definition: x400_att.h:981
int X400mtMsgDelete(struct X400mtMessage *mp)
Delete message object.
int X400mtACP127RespNew(struct X400mtMessage *mp, struct X400ACP127Resp **respp)
Create an ACP127 Notification Response object.
#define X400_N_AUTOFORWARDED
Definition: x400_att.h:745
#define X400_S_MESSAGE_DELIVERY_TIME
Definition: x400_att.h:439