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