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

All rights reserved © 2002 - 2024 Isode Ltd.