diff options
Diffstat (limited to 'ipsec-tools')
-rw-r--r-- | ipsec-tools/src/libipsec/pfkey.c | 7 | ||||
-rw-r--r-- | ipsec-tools/src/racoon/rtems-bsd-racoon-session-data.h | 6 | ||||
-rw-r--r-- | ipsec-tools/src/racoon/session.c | 47 |
3 files changed, 57 insertions, 3 deletions
diff --git a/ipsec-tools/src/libipsec/pfkey.c b/ipsec-tools/src/libipsec/pfkey.c index a621be12..385a21a9 100644 --- a/ipsec-tools/src/libipsec/pfkey.c +++ b/ipsec-tools/src/libipsec/pfkey.c @@ -1,5 +1,12 @@ #include <machine/rtems-bsd-user-space.h> +#ifdef __rtems__ +/* Only need socket from rtems-bsd-program wrappers! */ +int +rtems_bsd_program_socket(int domain, int type, int protocol); +#define socket(domain, type, protocol) \ + rtems_bsd_program_socket(domain, type, protocol) +#endif /* __rtems__ */ /* $NetBSD: pfkey.c,v 1.21.2.1 2011/11/14 13:25:06 tteras Exp $ */ /* $KAME: pfkey.c,v 1.47 2003/10/02 19:52:12 itojun Exp $ */ diff --git a/ipsec-tools/src/racoon/rtems-bsd-racoon-session-data.h b/ipsec-tools/src/racoon/rtems-bsd-racoon-session-data.h index 9a1b03f1..196107a3 100644 --- a/ipsec-tools/src/racoon/rtems-bsd-racoon-session-data.h +++ b/ipsec-tools/src/racoon/rtems-bsd-racoon-session-data.h @@ -2,11 +2,11 @@ #include <rtems/linkersets.h> #include "rtems-bsd-racoon-data.h" /* session.c */ -RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static _types_fd_set active_mask); -RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static _types_fd_set preset_mask); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static _types_fd_set *allocated_active_mask); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static _types_fd_set *allocated_preset_mask); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static int nfds); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static int signals[]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static sig_atomic_t volatile volatile sigreq[]); -RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static struct fd_monitor fd_monitors[]); +RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static struct fd_monitor *allocated_fd_monitors); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static struct fd_monitor_list fd_monitor_tree[]); RTEMS_LINKER_RWSET_CONTENT(bsd_prog_racoon, static struct sched scflushsa); diff --git a/ipsec-tools/src/racoon/session.c b/ipsec-tools/src/racoon/session.c index 65124c15..77e4f6f6 100644 --- a/ipsec-tools/src/racoon/session.c +++ b/ipsec-tools/src/racoon/session.c @@ -65,6 +65,10 @@ #include <sys/stat.h> #include <paths.h> #include <err.h> +#ifdef __rtems__ +#include <sys/param.h> +#include <rtems/libio_.h> +#endif /* __rtems__ */ #include <netinet/in.h> #include <resolv.h> @@ -123,8 +127,16 @@ static void check_sigreq __P((void)); static void check_flushsa __P((void)); static int close_sockets __P((void)); +#ifndef __rtems__ static fd_set preset_mask, active_mask; static struct fd_monitor fd_monitors[FD_SETSIZE]; +#else /* __rtems__ */ +static fd_set *allocated_preset_mask, *allocated_active_mask; +static struct fd_monitor *allocated_fd_monitors; +#define preset_mask (*allocated_preset_mask) +#define active_mask (*allocated_active_mask) +#define fd_monitors (allocated_fd_monitors) +#endif /* __rtems__ */ static TAILQ_HEAD(fd_monitor_list, fd_monitor) fd_monitor_tree[NUM_PRIORITIES]; static int nfds = 0; @@ -134,7 +146,11 @@ static struct sched scflushsa = SCHED_INITIALIZER(); void monitor_fd(int fd, int (*callback)(void *, int), void *ctx, int priority) { +#ifndef __rtems__ if (fd < 0 || fd >= FD_SETSIZE) { +#else /* __rtems__ */ + if (fd < 0 || fd >= rtems_libio_number_iops) { +#endif /* __rtems__ */ plog(LLV_ERROR, LOCATION, NULL, "fd_set overrun"); exit(1); } @@ -158,7 +174,11 @@ monitor_fd(int fd, int (*callback)(void *, int), void *ctx, int priority) void unmonitor_fd(int fd) { +#ifndef __rtems__ if (fd < 0 || fd >= FD_SETSIZE) { +#else /* __rtems__ */ + if (fd < 0 || fd >= rtems_libio_number_iops) { +#endif /* __rtems__ */ plog(LLV_ERROR, LOCATION, NULL, "fd_set overrun"); exit(1); } @@ -186,7 +206,24 @@ session(void) struct fd_monitor *fdm; nfds = 0; +#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) + errx(1, "failed to allocate preset_mask"); + allocated_active_mask = calloc(sizeof(fd_set), + howmany(rtems_libio_number_iops, sizeof(fd_set) * 8)); + if (allocated_active_mask == NULL) + errx(1, "failed to allocate active_mask"); + allocated_fd_monitors = calloc( + rtems_libio_number_iops, sizeof(struct fd_monitor)); + if (allocated_fd_monitors == NULL) + errx(1, "failed to allocate fd_monitors"); +#endif /* __rtems__ */ for (i = 0; i < NUM_PRIORITIES; i++) TAILQ_INIT(&fd_monitor_tree[i]); @@ -307,7 +344,12 @@ session(void) /* 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) { @@ -356,6 +398,11 @@ 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()); |