#include "routers/rf_functions.h"
-#ifdef ROUTER_ACCEPT
-# include "routers/accept.h"
-#endif
-
+/*XXX delete */
#ifdef ROUTER_DNSLOOKUP
# include "routers/dnslookup.h"
#endif
/* Now set up the structures, terminated by an entry with a null name. */
router_info routers_available_oldarray[] = {
-#ifdef ROUTER_ACCEPT
- {
- .drinfo = {
- .driver_name = US"accept",
- .options = accept_router_options,
- .options_count = &accept_router_options_count,
- .options_block = &accept_router_option_defaults,
- .options_len = sizeof(accept_router_options_block),
- .init = accept_router_init,
- },
- .code = accept_router_entry,
- .tidyup = NULL, /* no tidyup entry */
- .ri_flags = ri_yestransport
- },
-#endif
-#ifdef ROUTER_DNSLOOKUP
- {
- .drinfo = {
- .driver_name = US"dnslookup",
- .options = dnslookup_router_options,
- .options_count = &dnslookup_router_options_count,
- .options_block = &dnslookup_router_option_defaults,
- .options_len = sizeof(dnslookup_router_options_block),
- .init = dnslookup_router_init,
- },
- .code = dnslookup_router_entry,
- .tidyup = NULL, /* no tidyup entry */
- .ri_flags = ri_yestransport
- },
-#endif
-#ifdef ROUTER_IPLITERAL
- {
- .drinfo = {
- .driver_name = US"ipliteral",
- .options = ipliteral_router_options,
- .options_count = &ipliteral_router_options_count,
- .options_block = &ipliteral_router_option_defaults,
- .options_len = sizeof(ipliteral_router_options_block),
- .init = ipliteral_router_init,
- },
- .code = ipliteral_router_entry,
- .tidyup = NULL, /* no tidyup entry */
- .ri_flags = ri_yestransport
- },
-#endif
-#ifdef ROUTER_IPLOOKUP
- {
- .drinfo = {
- .driver_name = US"iplookup",
- .options = iplookup_router_options,
- .options_count = &iplookup_router_options_count,
- .options_block = &iplookup_router_option_defaults,
- .options_len = sizeof(iplookup_router_options_block),
- .init = iplookup_router_init,
- },
- .code = iplookup_router_entry,
- .tidyup = NULL, /* no tidyup entry */
- .ri_flags = ri_notransport
- },
-#endif
-#ifdef ROUTER_MANUALROUTE
- {
- .drinfo = {
- .driver_name = US"manualroute",
- .options = manualroute_router_options,
- .options_count = &manualroute_router_options_count,
- .options_block = &manualroute_router_option_defaults,
- .options_len = sizeof(manualroute_router_options_block),
- .init = manualroute_router_init,
- },
- .code = manualroute_router_entry,
- .tidyup = NULL, /* no tidyup entry */
- .ri_flags = 0
- },
-#endif
-#ifdef ROUTER_REDIRECT
- {
- .drinfo = {
- .driver_name = US"redirect",
- .options = redirect_router_options,
- .options_count = &redirect_router_options_count,
- .options_block = &redirect_router_option_defaults,
- .options_len = sizeof(redirect_router_options_block),
- .init = redirect_router_init,
- },
- .code = redirect_router_entry,
- .tidyup = NULL, /* no tidyup entry */
- .ri_flags = ri_notransport
- },
-#endif
{ .drinfo = { .driver_name = US"" }}
};
};
#ifdef DYNLOOKUP
-#define cdb_lookup_module_info _lookup_module_info
+# define cdb_lookup_module_info _lookup_module_info
#endif
static lookup_info *_lookup_list[] = { &cdb_lookup_info };
* Initialize router list *
*************************************************/
+/*XXX will likely want to rename to generic */
+
+static void
+add_router(driver_info ** drlist_p, const driver_info * newent, size_t size)
+{
+driver_info * listent = store_get(size, newent);
+memcpy(listent, newent, size);
+listent->next = *drlist_p;
+*drlist_p= listent;
+}
+
/* Read the routers section of the configuration file, and set up a chain of
router instances according to its contents. Each router has generic options and
may also have its own private options. This function is only ever called when
void
route_init(void)
{
-/*XXX temp loop just copying the old array to build the new list.
-Will replace with haul from either static build file or dyn module
-done by readconf_driver_init() */
+#ifdef old
+/*XXX temp loop just copying the old array to build the new list. */
for (router_info * tblent = routers_available_oldarray;
*tblent->drinfo.driver_name; tblent++)
{
listent->next = (driver_info *)routers_available_newlist;
routers_available_newlist = (router_info *)listent;
}
+#else
+
+/*XXX
+Will replace with ifdeffed explicit calls in drtab.c just building list
+(2 lists?) of names for -bV (DONE),
+plut ifdeffed repeated code here adding static-build modules to list (DONE)
+plus code in readconf.c for dlopen()s just before per-driver init api call.
+*/
+
+int old_pool = store_pool;
+store_pool = POOL_PERM;
+ {
+ driver_info ** anchor = (driver_info **) &routers_available_newlist;
+ extern router_info accept_router_info;
+ extern router_info dnslookup_router_info;
+ extern router_info ipliteral_router_info;
+ extern router_info iplookup_router_info;
+ extern router_info manualroute_router_info;
+ extern router_info redirect_router_info;
+ extern router_info queryprogram_router_info;
+
+ /*XXX this addsonly the statics. We can't get the dynamics as they
+ are not linked. Until dlopen(), when we can use dlsym(). So the discovery
+ is by the file exitence, via the filename pattern. */
+ /*XXX TODO: move the info structs to individual driver files */
+#if defined(ROUTER_ACCEPT) && ROUTER_ACCEPT!=2
+ add_router(anchor, &accept_router_info.drinfo, sizeof(router_info));
+#endif
+#if defined(ROUTER_DNSLOOKUP) && ROUTER_DNSLOOKUP!=2
+ add_router(anchor, &dnslookup_router_info.drinfo, sizeof(router_info));
+#endif
+# if defined(ROUTER_IPLITERAL) && ROUTER_IPLITERAL!=2
+ add_router(anchor, &ipliteral_router_info.drinfo, sizeof(router_info));
+#endif
+#if defined(ROUTER_IPLOOKUP) && ROUTER_IPLOOKUP!=2
+ add_router(anchor, &iplookup_router_info.drinfo, sizeof(router_info));
+#endif
+#if defined(ROUTER_MANUALROUTE) && ROUTER_MANUALROUTE!=2
+ add_router(anchor, &manualroute_router_info.drinfo, sizeof(router_info));
+#endif
+#if defined(ROUTER_REDIRECT) && ROUTER_REDIRECT!=2
+ add_router(anchor, &redirect_router_info.drinfo, sizeof(router_info));
+#endif
+#if defined(ROUTER_QUERYPROGRAM) && ROUTER_QUERYPROGRAM!=2
+ add_router(anchor, &queryprogram_router_info.drinfo, sizeof(router_info));
+#endif
+ }
+store_pool = old_pool;
+
+#endif /*!old*/
+/*XXX this does the config file "routers" section reading */
readconf_driver_init((driver_instance **)&routers, /* chain anchor */
(driver_info *)routers_available_newlist, /* available drivers */
sizeof(router_info), /* size of info blocks */
return rf_queue_add(addr, addr_local, addr_remote, rblock, pw) ? OK : DEFER;
}
+
+
+# ifdef DYNLOOKUP
+# define accept_router_info _router_info
+# endif
+
+router_info accept_router_info =
+{
+.drinfo = {
+ .driver_name = US"accept",
+ .options = accept_router_options,
+ .options_count = &accept_router_options_count,
+ .options_block = &accept_router_option_defaults,
+ .options_len = sizeof(accept_router_options_block),
+ .init = accept_router_init,
+# ifdef DYNLOOKUP
+ .dyn_magic = ROUTER_MAGIC, /*XXX*/
+# endif
+ },
+.code = accept_router_entry,
+.tidyup = NULL, /* no tidyup entry */
+.ri_flags = ri_yestransport
+};
+
#endif /*!MACRO_PREDEF*/
#endif /*ROUTER_ACCEPT*/
return rf_queue_add(addr, addr_local, addr_remote, rblock, pw) ? OK : DEFER;
}
+
+
+
+# ifdef DYNLOOKUP
+# define dnslookup_router_info _router_info
+# endif
+
+router_info dnslookup_router_info =
+{
+.drinfo = {
+ .driver_name = US"dnslookup",
+ .options = dnslookup_router_options,
+ .options_count = &dnslookup_router_options_count,
+ .options_block = &dnslookup_router_option_defaults,
+ .options_len = sizeof(dnslookup_router_options_block),
+ .init = dnslookup_router_init,
+# ifdef DYNLOOKUP
+ .dyn_magic = ROUTER_MAGIC, /*XXX*/
+# endif
+ },
+.code = dnslookup_router_entry,
+.tidyup = NULL, /* no tidyup entry */
+.ri_flags = ri_yestransport
+};
+
#endif /*!MACRO_PREDEF*/
#endif /*ROUTER_DNSLOOKUP*/
/* End of routers/dnslookup.c */
OK : DEFER;
}
+
+
+# ifdef DYNLOOKUP
+# define ipliteral_router_info _router_info
+# endif
+
+router_info ipliteral_router_info =
+{
+.drinfo = {
+ .driver_name = US"ipliteral",
+ .options = ipliteral_router_options,
+ .options_count = &ipliteral_router_options_count,
+ .options_block = &ipliteral_router_option_defaults,
+ .options_len = sizeof(ipliteral_router_options_block),
+ .init = ipliteral_router_init,
+# ifdef DYNLOOKUP
+ .dyn_magic = ROUTER_MAGIC, /*XXX*/
+# endif
+ },
+.code = ipliteral_router_entry,
+.tidyup = NULL, /* no tidyup entry */
+.ri_flags = ri_yestransport
+};
+
#endif /*!MACRO_PREDEF*/
#endif /*ROUTER_IPLITERAL*/
/* End of routers/ipliteral.c */
return OK;
}
+
+
+# ifdef DYNLOOKUP
+# define iplookup_router_info _router_info
+# endif
+
+router_info iplookup_router_info =
+{
+.drinfo = {
+ .driver_name = US"iplookup",
+ .options = iplookup_router_options,
+ .options_count = &iplookup_router_options_count,
+ .options_block = &iplookup_router_option_defaults,
+ .options_len = sizeof(iplookup_router_options_block),
+ .init = iplookup_router_init,
+# ifdef DYNLOOKUP
+ .dyn_magic = ROUTER_MAGIC, /*XXX*/
+# endif
+ },
+.code = iplookup_router_entry,
+.tidyup = NULL, /* no tidyup entry */
+.ri_flags = ri_notransport
+};
+
#endif /*!MACRO_PREDEF*/
#endif /*ROUTER_IPLOOKUP*/
/* End of routers/iplookup.c */
return OK;
}
+
+
+
+# ifdef DYNLOOKUP
+# define manualroute_router_info _router_info
+# endif
+
+router_info manualroute_router_info =
+{
+.drinfo = {
+ .driver_name = US"manualroute",
+ .options = manualroute_router_options,
+ .options_count = &manualroute_router_options_count,
+ .options_block = &manualroute_router_option_defaults,
+ .options_len = sizeof(manualroute_router_options_block),
+ .init = manualroute_router_init,
+# ifdef DYNLOOKUP
+ .dyn_magic = ROUTER_MAGIC, /*XXX*/
+# endif
+ },
+.code = manualroute_router_entry,
+.tidyup = NULL, /* no tidyup entry */
+.ri_flags = 0
+};
+
#endif /*!MACRO_PREDEF*/
#endif /*ROUTER_MANUALROUTE*/
/* End of routers/manualroute.c */
return rf_queue_add(addr, addr_local, addr_remote, rblock, pw) ? OK : DEFER;
}
+
+
+# ifdef DYNLOOKUP
+# define queryprogram_router_info _router_info
+# endif
+
+router_info queryprogram_router_info =
+{
+.drinfo = {
+ .driver_name = US"queryprogram",
+ .options = queryprogram_router_options,
+ .options_count = &queryprogram_router_options_count,
+ .options_block = &queryprogram_router_option_defaults,
+ .options_len = sizeof(queryprogram_router_options_block),
+ .init = queryprogram_router_init,
+# ifdef DYNLOOKUP
+ .dyn_magic = ROUTER_MAGIC, /*XXX*/
+# endif
+ },
+.code = queryprogram_router_entry,
+.tidyup = NULL, /* no tidyup entry */
+.ri_flags = 0
+};
+
#endif /*!MACRO_PREDEF*/
#endif /*ROUTER_QUERYPROGRAM*/
/* End of routers/queryprogram.c */
return yield;
}
+
+
+# ifdef DYNLOOKUP
+# define redirect_router_info _router_info
+# endif
+
+router_info redirect_router_info =
+{
+.drinfo = {
+ .driver_name = US"redirect",
+ .options = redirect_router_options,
+ .options_count = &redirect_router_options_count,
+ .options_block = &redirect_router_option_defaults,
+ .options_len = sizeof(redirect_router_options_block),
+ .init = redirect_router_init,
+# ifdef DYNLOOKUP
+ .dyn_magic = ROUTER_MAGIC, /*XXX*/
+# endif
+ },
+.code = redirect_router_entry,
+.tidyup = NULL, /* no tidyup entry */
+.ri_flags = ri_notransport
+};
+
#endif /*!MACRO_PREDEF*/
#endif /*ROUTER_REDIRECT*/
/* End of routers/redirect.c */
int options_len; /* Length of same in bytes */
void (*init)( /* Initialization entry point */
struct driver_instance *);
- BOOL dynamic; /* Built as dynamic-load module */
+ uint dyn_magic; /* Magic num if dynamic, else zero */
} driver_info;
+/* Values for dyn_magic. Encode types and api version. */
+#define ROUTER_MAGIC 0x52544d31 /* RTM1 */
+#define TRANSPORT_MAGIC 0x54504d31 /* TPM1 */
+#define AUTH_MAGIC 0x65554d31 /* AUM1 */
+
/* Structure for holding information about the configured transports. Some
of the generally accessible options are set from the configuration file; others