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