? ldap Index: Makefile.in =================================================================== RCS file: /home/cvs/gateway/Makefile.in,v retrieving revision 1.85 diff -u -r1.85 Makefile.in --- Makefile.in 24 Jun 2008 15:05:24 -0000 1.85 +++ Makefile.in 4 Jul 2008 13:44:43 -0000 @@ -91,6 +91,8 @@ HTML_DSL=@HTML_DSL@ TEX_DSL=@TEX_DSL@ +WAPSRCS=@WAPSRCS@ + # Set this to something if you want all installed binaries to have a suffix. # Version number is common. suffix = $(SUFFIX) @@ -125,7 +127,7 @@ libsrcs = $(wildcard gwlib/*.c) $(LIBSRCS) libobjs = $(libsrcs:.c=.o) $(LIBOBJS) -wapsrcs = $(wildcard wap/*.c) $(wildcard radius/*.c) +wapsrcs = $(wildcard wap/*.c) $(wildcard radius/*.c) $(WAPSRCS) wapobjs = $(wapsrcs:.c=.o) wmlscriptsrcs = $(wildcard wmlscript/*.c) Index: configure =================================================================== RCS file: /home/cvs/gateway/configure,v retrieving revision 1.169 diff -u -r1.169 configure --- configure 2 Jul 2008 14:56:31 -0000 1.169 +++ configure 4 Jul 2008 13:44:45 -0000 @@ -711,7 +711,8 @@ SQLITE SQLITE3 PGSQL_CONFIG -LTLIBOBJS' +LTLIBOBJS +WAPSRCS' ac_subst_files='' ac_precious_vars='build_alias host_alias @@ -13335,6 +13336,32 @@ + { echo "$as_me:$LINENO: checking whether to compile with LDAP provisioning support" >&5 +echo $ECHO_N "checking whether to compile with LDAP provisioning support... $ECHO_C" >&6; } +# Check whether --disable-ldap was given. +if test "${enable_ldap+set}" = set; then + enableval="$enable_ldap" + + if test "$enableval" = "no" + then + { echo "$as_me:$LINENO:result: disabled" >&5 +echo "${ECHO_T}disabled" >&6;} + +cat >>confdefs.h <<\_ACEOF +#define NO_LDAP_PROVISIONING 1 +_ACEOF + else + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6;} + LIBS="$LIBS -lldap" + WAPSRCS="ldap/ldap_acct.c" + fi + else + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6;} + LIBS="$LIBS -lldap" + WAPSRCS="ldap/ldap_acct.c" +fi; @@ -14304,9 +14331,10 @@ SDB_CONFIG!$SDB_CONFIG$ac_delim SQLITE!$SQLITE$ac_delim SQLITE3!$SQLITE3$ac_delim +WAPSRCS!$WAPSRCS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 98; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 Index: gw-config.h.in =================================================================== RCS file: /home/cvs/gateway/gw-config.h.in,v retrieving revision 1.20 diff -u -r1.20 gw-config.h.in --- gw-config.h.in 9 Jan 2008 20:07:01 -0000 1.20 +++ gw-config.h.in 4 Jul 2008 13:44:45 -0000 @@ -241,6 +241,9 @@ /* Define not to include the SMS gateway parts */ #undef NO_SMS +/* Define not to include LDAP msisdn provisioning in wapbox */ +#undef NO_LDAP_PROVISIONING + /* Define for various gethostbyname_r functions */ #undef HAVE_FUNC_GETHOSTBYNAME_R_6 #undef HAVE_FUNC_GETHOSTBYNAME_R_5 Index: gw/wap-appl.c =================================================================== RCS file: /home/cvs/gateway/gw/wap-appl.c,v retrieving revision 1.123 diff -u -r1.123 wap-appl.c --- gw/wap-appl.c 5 Mar 2008 08:01:06 -0000 1.123 +++ gw/wap-appl.c 4 Jul 2008 13:44:45 -0000 @@ -98,7 +98,7 @@ #ifdef ENABLE_COOKIES #include "wap/cookies.h" #endif -#include "radius/radius_acct.h" +/* #include "radius/radius_acct.h" */ /* not needed anymore */ #include "wap-error.h" #include "wap-maps.h" @@ -176,6 +176,11 @@ static int have_ppg = 0; /* + * Storage backend msisdn provisioning + */ +extern Octstr (*(*storage_acct_get_msisdn)(Octstr *client_ip)); + +/* * Private functions. */ @@ -631,7 +636,7 @@ */ /* We do not accept NULL values to be added to the HTTP header */ - if ((msisdn = radius_acct_get_msisdn(addr_tuple->remote->address)) != NULL) { + if ((msisdn = (*storage_acct_get_msisdn)(addr_tuple->remote->address)) != NULL) { http_header_add(headers, octstr_get_cstr(send_msisdn_header), octstr_get_cstr(msisdn)); } @@ -1151,7 +1156,7 @@ method = p->method; } - msisdn = radius_acct_get_msisdn(addr_tuple->remote->address); + msisdn = (*storage_acct_get_msisdn)(addr_tuple->remote->address); /* use a general call to a storage backend */ info(0, "Fetching URL <%s> for MSISDN <%s>, IP <%s:%ld>", octstr_get_cstr(url), msisdn ? octstr_get_cstr(msisdn) : "", addr_tuple->remote->address ? octstr_get_cstr(addr_tuple->remote->address) : "", Index: gw/wapbox.c =================================================================== RCS file: /home/cvs/gateway/gw/wapbox.c,v retrieving revision 1.185 diff -u -r1.185 wapbox.c --- gw/wapbox.c 9 Jan 2008 20:06:57 -0000 1.185 +++ gw/wapbox.c 4 Jul 2008 13:44:45 -0000 @@ -85,6 +85,10 @@ #endif #include "radius/radius_acct.h" +#ifndef NO_LDAP_PROVISIONING +#include "ldap/ldap_acct.h" +#endif + static void config_reload(int reload); static long logfilelevel=-1; @@ -120,6 +124,34 @@ X509* x509_cert = NULL; #endif +/* The pointer to a function doing the actual provisioning lookup via one of the backends */ +Octstr (*(*storage_acct_get_msisdn)(Octstr *client_ip)); +/* Functions for starting/stopping storage backends */ +static void (*storage_acct_init)(CfgGroup *grp); +static void (*storage_acct_shutdown)(void); +static Octstr *msisdn_storage; /* for reference */ + +/* two functions for switching storages */ +#ifndef NO_LDAP_PROVISIONING +static void switch_ldap_msisdn_storage() { +storage_acct_get_msisdn = ldap_acct_get_msisdn; +storage_acct_init = ldap_acct_init; +storage_acct_shutdown = ldap_acct_shutdown; +msisdn_storage = octstr_imm("ldap-acct"); +} +#endif + +static void switch_radius_msisdn_storage() { +storage_acct_get_msisdn = radius_acct_get_msisdn; +storage_acct_init = radius_acct_init; +storage_acct_shutdown = radius_acct_shutdown; +msisdn_storage = octstr_imm("radius-acct"); +} + +static Octstr *get_msisdn_storage() { +return msisdn_storage; +} + static Cfg *init_wapbox(Cfg *cfg) { CfgGroup *grp; @@ -200,6 +232,27 @@ octstr_destroy(s); } + /* choose msisdn provisioning type */ + if ((s = cfg_get(grp, octstr_imm("msisdn-storage"))) != NULL) { +#ifndef NO_LDAP_PROVISIONING + if (octstr_compare(s, octstr_imm("ldap")) == 0) { + switch_ldap_msisdn_storage(); + } + else +#endif + if (octstr_compare(s, octstr_imm("radius")) == 0) { + switch_radius_msisdn_storage(); + } else panic(0, "msisdn-storage: unknown storage type in wapbox group."); + + info(0, "Using %s as the msisdn provisioning backend.", octstr_get_cstr(s)); +#ifndef NO_LDAP_PROVISIONING + } else { + /* radius is the default behavior */ + switch_radius_msisdn_storage(); +#endif + } + + /* configure the 'wtls' group */ #if (HAVE_WTLS_OPENSSL) /* Load up the necessary keys */ @@ -237,14 +290,13 @@ panic(0, "No 'privatekey-file' in wtls group"); } #endif - /* - * Check if we have a 'radius-acct' proxy group and start the + * Check if we have a 'radius-acct' or 'ldap-acct' proxy group and start the * corresponding thread for the proxy. */ - grp = cfg_get_single_group(cfg, octstr_imm("radius-acct")); + grp = cfg_get_single_group(cfg, get_msisdn_storage()); if (grp) { - radius_acct_init(grp); + storage_acct_init(grp); /* start msisdn storage backend */ } /* @@ -822,7 +874,8 @@ wsp_unit_shutdown(); wsp_session_shutdown(); wap_appl_shutdown(); - radius_acct_shutdown(); + + storage_acct_shutdown(); if (cfg) { wap_push_ota_shutdown(); Index: gw/wapkannel.conf =================================================================== RCS file: /home/cvs/gateway/gw/wapkannel.conf,v retrieving revision 1.14 diff -u -r1.14 wapkannel.conf --- gw/wapkannel.conf 9 Jan 2006 20:42:08 -0000 1.14 +++ gw/wapkannel.conf 4 Jul 2008 13:44:45 -0000 @@ -44,5 +44,24 @@ #log-level = 0 syslog-level = none #access-log = "/tmp/wapaccess.log" +msisdn-storage = ldap + +group = ldap-acct +lookup_table_size = 30 +servers = "ldap://host1 ldap://10.1.1.1:389 ldap://otherhost" +#bind_dn = "cn:uid=pylypchuk,ou=people,dc=sonopia,dc=com" +#bind_passwd = "secret" +search_dn = "ou=people,dc=sonopia,dc=com" +search_filter = "msisdn=%s" +search_attr_name = "ip" +cache_stale_time = 1 +ip_timeout_s = 2 +ip_timeout_mrs = 0 +retries_x = 2 +retries_y = 2 +retries_z = 2 +dummy_request_interval = 5 +dummy_request_ip = 10.1.3.223 + Index: gwlib/cfg.def =================================================================== RCS file: /home/cvs/gateway/gwlib/cfg.def,v retrieving revision 1.133 diff -u -r1.133 cfg.def --- gwlib/cfg.def 24 Jun 2008 09:10:04 -0000 1.133 +++ gwlib/cfg.def 4 Jul 2008 13:44:45 -0000 @@ -159,6 +159,7 @@ OCTSTR(concatenation) OCTSTR(max-messages) OCTSTR(wml-strict) + OCTSTR(msisdn-storage) ) @@ -581,6 +582,24 @@ OCTSTR(unified-prefix) ) +SINGLE_GROUP(ldap-acct, + OCTSTR(lookup_table_size) + OCTSTR(servers) + OCTSTR(bind_dn) + OCTSTR(bind_passwd) + OCTSTR(search_dn) + OCTSTR(search_filter) + OCTSTR(search_attr_name) + OCTSTR(cache_stale_time) + OCTSTR(ip_timeout_s) + OCTSTR(ip_timeout_mrs) + OCTSTR(retries_x) + OCTSTR(retries_y) + OCTSTR(retries_z) + OCTSTR(dummy_request_interval) + OCTSTR(dummy_request_ip); +) + #undef OCTSTR #undef SINGLE_GROUP #undef MULTI_GROUP