diff options
Diffstat (limited to 'ipsec-tools/src/racoon/session.c')
-rw-r--r-- | ipsec-tools/src/racoon/session.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/ipsec-tools/src/racoon/session.c b/ipsec-tools/src/racoon/session.c index 90120c76..bd2bd316 100644 --- a/ipsec-tools/src/racoon/session.c +++ b/ipsec-tools/src/racoon/session.c @@ -119,6 +119,7 @@ struct fd_monitor { #define NUM_PRIORITIES 2 +#ifndef __rtems__ static void close_session __P((void)); static void initfds __P((void)); static void init_signal __P((void)); @@ -126,6 +127,7 @@ static int set_signal __P((int sig, RETSIGTYPE (*func) __P((int)))); static void check_sigreq __P((void)); static void check_flushsa __P((void)); static int close_sockets __P((void)); +#endif /* __rtems__ */ #ifndef __rtems__ static fd_set preset_mask, active_mask; @@ -140,8 +142,10 @@ static struct fd_monitor *allocated_fd_monitors; static TAILQ_HEAD(fd_monitor_list, fd_monitor) fd_monitor_tree[NUM_PRIORITIES]; static int nfds = 0; +#ifndef __rtems__ static volatile sig_atomic_t sigreq[NSIG + 1]; static struct sched scflushsa = SCHED_INITIALIZER(); +#endif /* __rtems__ */ void monitor_fd(int fd, int (*callback)(void *, int), void *ctx, int priority) @@ -199,9 +203,11 @@ session(void) { struct timeval *timeout; int error; +#ifndef __rtems__ char pid_file[MAXPATHLEN]; FILE *fp; pid_t racoon_pid = 0; +#endif /* __rtems__ */ int i, count; struct fd_monitor *fdm; @@ -209,6 +215,8 @@ session(void) #ifndef __rtems__ FD_ZERO(&preset_mask); #else /* __rtems__ */ + size_t allocated_mask_size = sizeof(fd_set) * + howmany(rtems_libio_number_iops, sizeof(fd_set) * 8); allocated_preset_mask = calloc(sizeof(fd_set), howmany(rtems_libio_number_iops, sizeof(fd_set) * 8)); if (allocated_preset_mask == NULL) @@ -228,7 +236,9 @@ session(void) /* initialize schedular */ sched_init(); +#ifndef __rtems__ init_signal(); +#endif /* __rtems__ */ if (pfkey_init() < 0) errx(1, "failed to initialize pfkey socket"); @@ -325,24 +335,31 @@ session(void) racoon_pid = getpid(); fprintf(fp, "%ld\n", (long)racoon_pid); fclose(fp); -#endif /* __rtems__ */ for (i = 0; i <= NSIG; i++) sigreq[i] = 0; +#endif /* __rtems__ */ while (1) { +#ifndef __rtems__ /* * asynchronous requests via signal. * make sure to reset sigreq to 0. */ check_sigreq(); +#endif /* __rtems__ */ /* scheduling */ timeout = schedular(); /* schedular can change select() mask, so we reset * the working copy here */ +#ifndef __rtems__ active_mask = preset_mask; +#else /* __rtems__ */ + memcpy(allocated_active_mask, allocated_preset_mask, + allocated_mask_size); +#endif /* __rtems__ */ error = select(nfds + 1, &active_mask, NULL, NULL, timeout); if (error < 0) { @@ -379,6 +396,7 @@ session(void) } } +#ifndef __rtems__ /* clear all status and exit program. */ static void close_session() @@ -391,11 +409,6 @@ close_session() flushsainfo(); close_sockets(); backupsa_clean(); -#ifdef __rtems__ - free(allocated_preset_mask); allocated_preset_mask = NULL; - free(allocated_active_mask); allocated_active_mask = NULL; - free(allocated_fd_monitors); allocated_fd_monitors = NULL; -#endif /* __rtems__ */ plog(LLV_INFO, LOCATION, NULL, "racoon process %d shutdown\n", getpid()); @@ -565,11 +578,7 @@ set_signal(sig, func) memset((caddr_t)&sa, 0, sizeof(sa)); sa.sa_handler = func; -#ifndef __rtems__ sa.sa_flags = SA_RESTART; -#else /* __rtems__ */ - sa.sa_flags = 0; -#endif /* __rtems__ */ if (sigemptyset(&sa.sa_mask) < 0) return -1; @@ -590,6 +599,7 @@ close_sockets() #endif return 0; } +#endif /* __rtems__ */ #ifdef __rtems__ #include "rtems-bsd-racoon-session-data.h" |