[Previous] [Contents] [Index] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

ipsec_strerror()

Error code for IPsec policy manipultion library

Synopsis:

#include <netinet6/ipsec.h>

const char *
ipsec_strerror(void);

Library:

libipsec

Use the -l ipsec option to qcc to link against this library.

Description:

This ipsec_strerror() function is used to obtain the error message string from the last failed IPsec call.

Returns:

A pointer to an error message.


Note: Don't modify the string that this function returns.

Examples:

#include <netinet6/ipsec.h>
#include <sys/socket.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>

int
main(void)
{
   char *sadb;
   char *policy = "in discard";
   int len;

   sadb = ipsec_set_policy(policy, strlen(policy));

   if (sadb == NULL) {
      fprintf(stderr, "ipsec_set_policy: %s\n", ipsec_strerror());
      return 1;
   }

   len = ipsec_get_policylen(sadb);
   printf("len: %d\n", len);

   policy = NULL;
   policy = ipsec_dump_policy(sadb, NULL);

   if (policy == NULL) {
      fprintf(stderr, "ipsec_dump_policy: %s\n", ipsec_strerror());
      return 1;
   }

   printf("policy: %s\n", policy);

   free(policy);
   free(sadb);

   return 0;
}

Classification:

Unix

Safety:
Cancellation point No
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

IPsec, ipsec_dump_policy(), ipsec_get_policylen(), ipsec_set_policy()

setkey in the Utilities Reference


[Previous] [Contents] [Index] [Next]