Freeswitch-trunk
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
June 2008
- 9 participants
- 132 discussions
02 Jun '08
Author: anthm
Date: Mon Jun 2 11:42:59 2008
New Revision: 8737
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
Log:
some more presence changes
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Mon Jun 2 11:42:59 2008
@@ -743,7 +743,7 @@
}
-static char *gen_pidf(char *user_agent, char *id, char *url, char *open, char *rpid, char *prpid, char *status, char *note, const char **ct)
+static char *gen_pidf(char *user_agent, char *id, char *url, char *open, char *rpid, char *prpid, char *status, const char **ct)
{
if (switch_stristr("polycom", user_agent)) {
*ct = "application/xpidf+xml";
@@ -751,6 +751,9 @@
"<?xml version=\"1.0\"?>\n"
"<!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n"
"<presence>\n"
+ " <status>\n"
+ " <note>%s</note>\n"
+ " </status>\n"
" <presentity uri=\"%s;method=SUBSCRIBE\" />\n"
" <atom id=\"%s\">\n"
" <address uri=\"%s;user=ip\" priority=\"0.800000\">\n"
@@ -758,20 +761,17 @@
" <msnsubstatus substatus=\"%s\" />\n"
" </address>\n"
" </atom>\n"
- "</presence>\n", id, id, url, open, prpid
+ "</presence>\n", status, id, id, url, open, prpid
);
} else {
*ct = "application/pidf+xml";
return switch_mprintf(
- "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
- "<presence xmlns='urn:ietf:params:xml:ns:pidf'\n"
- "xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model'\n"
- "xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid'\n"
- "xmlns:c='urn:ietf:params:xml:ns:pidf:cipid'\n"
- "entity='pres:%s'>\n"
- " <status>\n"
- " <note>%s</note>\n"
- " </status>\n"
+ "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> \n"
+ "<presence xmlns='urn:ietf:params:xml:ns:pidf' \n"
+ "xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model' \n"
+ "xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid' \n"
+ "xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='%s'>\n"
+
" <tuple id='t6a5ed77e'>\n"
" <status>\r\n"
" <basic>%s</basic>\n"
@@ -780,9 +780,10 @@
" <dm:person id='p06360c4a'>\n"
" <rpid:activities>\r\n"
" <rpid:%s/>\n"
- " </rpid:activities>"
+ " </rpid:activities>\n"
+ " <dm:note>%s</dm:note>"
" </dm:person>\n"
- "</presence>", id, status, prpid, rpid);
+ "</presence>", id, prpid, rpid, status);
}
}
@@ -792,7 +793,7 @@
struct presence_helper *helper = (struct presence_helper *) pArg;
sofia_profile_t *profile = helper->profile;
char *pl = NULL;
- char *clean_id = NULL, *id = NULL, *note = NULL;
+ char *clean_id = NULL, *id = NULL;
uint32_t in = atoi(argv[13]);
char *status = argv[14];
char *rpid = argv[15];
@@ -910,9 +911,19 @@
if (!strcasecmp(state, "cs_hangup")) {
astate = "terminated";
} else if (switch_strlen_zero(astate)) {
+ //char *buf;
+ //switch_event_serialize(helper->event, &buf, SWITCH_FALSE);
+ //switch_assert(buf);
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "CHANNEL_DATA:\n%s\n", buf);
+ //free(buf);
+
astate = switch_str_nil(switch_event_get_header(helper->event, "answer-state"));
if (switch_strlen_zero(astate)) {
- astate = dft_state;
+ if (is_dialog) {
+ astate = dft_state;
+ } else {
+ astate = "terminated";
+ }
}
}
@@ -989,11 +1000,10 @@
if (!is_dialog) {
+ char status_line[256] = "";
if (in) {
- char status_line[256] = "";
-
if (!strcmp(astate, "early")) {
- switch_snprintf(status_line, sizeof(status_line), "R %s", switch_str_nil(from_id));
+ switch_snprintf(status_line, sizeof(status_line), "Ring %s", switch_str_nil(from_id));
rpid = "on-the-phone";
} else if (!strcmp(astate, "confirmed")) {
char *dest = switch_event_get_header(helper->event, "Caller-Destination-Number");
@@ -1002,36 +1012,42 @@
}
if (switch_strlen_zero(from_id)) {
- switch_snprintf(status_line, sizeof(status_line), "Available");
+ switch_snprintf(status_line, sizeof(status_line), "On The Phone");
} else {
- switch_snprintf(status_line, sizeof(status_line), "T %s", switch_str_nil(from_id));
- rpid = "on-the-phone";
+ switch_snprintf(status_line, sizeof(status_line), "Talk %s", switch_str_nil(from_id));
}
+ rpid = "on-the-phone";
} else if (!strcmp(astate, "terminated")) {
- switch_snprintf(status_line, sizeof(status_line), "Available");
+ if (!strcasecmp(rpid, "on-the-phone")) {
+ switch_snprintf(status_line, sizeof(status_line), "Dialing");
+ } else {
+ switch_snprintf(status_line, sizeof(status_line), "Available");
+ }
+ } else {
+ switch_set_string(status_line, status);
}
- note = switch_mprintf("<dm:note>%s</dm:note>", status_line);
open = "open";
} else {
- note = NULL;
open = "closed";
}
+
+ if (!strncasecmp(status_line, "registered", 10)) {
+ switch_snprintf(status_line, sizeof(status_line), "Available");
+ }
prpid = translate_rpid(rpid);
- pl = gen_pidf(user_agent, id, profile->url, open, rpid, prpid, status, note, &ct);
+ pl = gen_pidf(user_agent, clean_id, profile->url, open, rpid, prpid, status_line, &ct);
}
} else {
if (in) {
- note = switch_mprintf("<dm:note>%s</dm:note>", status);
open = "open";
} else {
- note = NULL;
open = "closed";
}
prpid = translate_rpid(rpid);
- pl = gen_pidf(user_agent, id, profile->url, open, rpid, prpid, status, note, &ct);
+ pl = gen_pidf(user_agent, clean_id, profile->url, open, rpid, prpid, status, &ct);
}
switch_snprintf(exp, sizeof(exp), "active;expires=%ld", (long) exptime);
@@ -1042,7 +1058,6 @@
switch_safe_free(id);
switch_safe_free(clean_id);
- switch_safe_free(note);
switch_safe_free(pl);
switch_safe_free(to);
1
0
01 Jun '08
Author: jskopis
Date: Sun Jun 1 15:48:20 2008
New Revision: 8736
Added:
freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/lutil_ldap.h
Modified:
freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/Makefile
freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c
Log:
Added sasl support.
Added support for search filters
Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/Makefile (original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/Makefile Sun Jun 1 15:48:20 2008
@@ -5,13 +5,14 @@
LDAPLA=$(LDAP_DIR)/libraries/libldap_r/libldap_r.la
LIBLBERLA=$(LDAP_DIR)/libraries/liblber/liblber.la
+LIBLUTILA=$(LDAP_DIR)/libraries/liblutil/liblutil.a
LOCAL_CFLAGS=-DWITH_OPENLDAP -DLDAP_DEPRECATED -I$(LDAP_DIR)/include
DEFAULT_ARGS= --prefix=$(PREFIX) --disable-shared --with-pic --disable-slapd
DEFAULT_ARGS+= --disable-slurpd --disable-relay --disable-bdb --disable-hdb
-LOCAL_LIBADD=$(LDAPLA) $(LIBLBERLA)
+LOCAL_LIBADD=$(LDAPLA) $(LIBLBERLA) $(LIBLUTILA)
include $(switch_srcdir)/build/modmake.rules
@@ -19,6 +20,6 @@
$(GETLIB) $(LDAP).tgz
cd $(LDAP_DIR) && CFLAGS="`echo $(CFLAGS) | sed -e 's:-std=c99::'`" ./configure $(DEFAULT_ARGS)
-$(LDAPLA) $(LIBLBERLA): $(LDAP_DIR)
+$(LIBLUTILA) $(LDAPLA) $(LIBLBERLA): $(LDAP_DIR)
cd $(LDAP_DIR) && $(MAKE)
$(TOUCH_TARGET)
Added: freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/lutil_ldap.h
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/lutil_ldap.h Sun Jun 1 15:48:20 2008
@@ -0,0 +1,58 @@
+/* $OpenLDAP: pkg/ldap/include/lutil_ldap.h,v 1.9.2.4 2008/02/11 23:24:10 kurt Exp $ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2008 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+
+#ifndef _LUTIL_LDAP_H
+#define _LUTIL_LDAP_H 1
+
+#include <ldap_cdefs.h>
+#include <lber_types.h>
+
+/*
+ * Include file for lutil LDAP routines
+ */
+
+LDAP_BEGIN_DECL
+
+LDAP_LUTIL_F( void )
+lutil_sasl_freedefs LDAP_P((
+ void *defaults ));
+
+LDAP_LUTIL_F( void * )
+lutil_sasl_defaults LDAP_P((
+ LDAP *ld,
+ char *mech,
+ char *realm,
+ char *authcid,
+ char *passwd,
+ char *authzid ));
+
+LDAP_LUTIL_F( int )
+lutil_sasl_interact LDAP_P((
+ LDAP *ld, unsigned flags, void *defaults, void *p ));
+
+LDAP_END_DECL
+
+#endif /* _LUTIL_LDAP_H */
+
+typedef struct lutil_sasl_defaults_s {
+ char *mech;
+ char *realm;
+ char *authcid;
+ char *passwd;
+ char *authzid;
+ char **resps;
+ int nresps;
+} lutilSASLdefaults;
+
Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c (original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c Sun Jun 1 15:48:20 2008
@@ -42,6 +42,8 @@
#else
#include <lber.h>
#include <ldap.h>
+#include <sasl/sasl.h>
+#include "lutil_ldap.h"
#endif
typedef enum {
@@ -55,18 +57,18 @@
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_ldap_shutdown);
SWITCH_MODULE_DEFINITION(mod_xml_ldap, mod_xml_ldap_load, mod_xml_ldap_shutdown, NULL);
-struct xml_binding {
+typedef struct xml_binding {
char *bindings;
char *host;
- char *ldap_base;
+ char *basedn;
char *binddn;
char *bindpass;
- char *queryfmt;
-};
+ char *filter;
+ char **attrs;
+ lutilSASLdefaults *defaults;
+} xml_binding_t;
-typedef struct xml_binding xml_binding_t;
-
-struct ldap_c {
+typedef struct ldap_c {
LDAP *ld;
LDAPMessage *msg;
LDAPMessage *entry;
@@ -76,8 +78,8 @@
char *val;
char **keyvals;
char **valvals;
-
-};
+ char *sp;
+} ldap_ctx;
static switch_status_t xml_ldap_directory_result(void *ldap_connection, xml_binding_t *binding, switch_xml_t *xml, int *off);
static switch_status_t xml_ldap_dialplan_result(void *ldap_connection, xml_binding_t *binding, switch_xml_t *xml, int *off);
@@ -223,10 +225,12 @@
int desired_version = LDAP_VERSION3;
xml_ldap_query_type_t query_type;
char *dir_exten = NULL, *dir_domain = NULL;
- char *filter = "(objectClass=*)";
- char *search_base = NULL;
- int off = 0;
+ char *search_filter = NULL, *search_base = NULL;
+ int off = 0, ret = 1;
+
+ //char *buf;
+ //buf = malloc(4096);
if (!binding) {
@@ -287,15 +291,18 @@
if ((sub = switch_xml_add_child_d(sub, "user", off++))) {
switch_xml_set_attr_d(sub, "id", dir_exten);
}
+
}
- search_base = switch_mprintf(binding->queryfmt, dir_exten, dir_domain, binding->ldap_base);
+ search_filter = switch_mprintf(binding->filter, dir_exten);
+ search_base = switch_mprintf(binding->basedn, dir_domain);
free(dir_exten);
dir_exten = NULL;
free(dir_domain);
dir_domain = NULL;
+
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"something bad happened during the query construction phase likely exten(%s) or domain(%s) is null\n", dir_exten,
@@ -314,7 +321,7 @@
sub = switch_xml_add_child_d(xml, "context", off++);
}
- search_base = switch_mprintf(binding->queryfmt, dir_exten, dir_domain, binding->ldap_base);
+
break;
case XML_LDAP_PHRASE:
@@ -327,7 +334,7 @@
- if ((ldap->ld = ldap_init(binding->host, LDAP_PORT)) == NULL) {
+ if ((ldap->ld = (LDAP*)ldap_init(binding->host, LDAP_PORT)) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to connect to ldap server.%s\n", binding->host);
goto cleanup;
}
@@ -336,12 +343,24 @@
goto cleanup;
}
- if (ldap_bind_s(ldap->ld, binding->binddn, binding->bindpass, auth_method) != LDAP_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to bind to ldap server %s as %s\n", binding->host, binding->binddn);
- goto cleanup;
+ ldap_set_option( ldap->ld, LDAP_OPT_X_SASL_SECPROPS, &ldap->sp );
+
+
+
+ if (binding->binddn) {
+ if (ldap_bind_s(ldap->ld, binding->binddn, binding->bindpass, auth_method) != LDAP_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to bind to ldap server %s as %s\n", binding->host, binding->binddn);
+ goto cleanup;
+ }
+ } else {
+ if (ldap_sasl_interactive_bind_s( ldap->ld, NULL, binding->defaults->mech, NULL, NULL,(unsigned)LDAP_SASL_SIMPLE, lutil_sasl_interact , binding->defaults ) != LDAP_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to sasl_bind to ldap server %s as %s\n", binding->host, binding->defaults->authcid);
+ goto cleanup;
+ }
}
- if (ldap_search_s(ldap->ld, search_base, LDAP_SCOPE_SUBTREE, filter, NULL, 0, &ldap->msg) != LDAP_SUCCESS) {
+ if (ldap_search_s(ldap->ld, search_base, LDAP_SCOPE_SUBTREE, search_filter, NULL, 0, &ldap->msg) != LDAP_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Query failed: -b \"%s\" \"%s\"\n", search_base, search_filter);
goto cleanup;
}
@@ -353,6 +372,8 @@
goto cleanup;
}
+ ret = 0;
+
cleanup:
if (ldap->msg) {
ldap_msgfree(ldap->msg);
@@ -362,8 +383,17 @@
ldap_unbind_s(ldap->ld);
}
+ switch_safe_free(search_filter);
switch_safe_free(search_base);
+ //switch_xml_toxml_buf(xml,buf,0,0,1);
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "providing:\n%s\n", buf);
+
+ if(ret) {
+ switch_xml_free(xml);
+ return NULL;
+ }
+
return xml;
}
@@ -393,35 +423,50 @@
}
memset(binding, 0, sizeof(*binding));
+ if (!(binding->defaults = malloc(sizeof(lutilSASLdefaults)))) {
+ goto done;
+ }
+ memset(binding->defaults, 0, sizeof(lutilSASLdefaults));
+
for (param = switch_xml_child(binding_tag, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
- if (!strcasecmp(var, "queryfmt")) {
+ if (!strcasecmp(var, "filter")) {
binding->bindings = (char *) switch_xml_attr_soft(param, "bindings");
if (val) {
- binding->queryfmt = strdup(val);
+ binding->filter = strdup(val);
}
- } else if (!strcasecmp(var, "base")) {
- binding->ldap_base = strdup(val);
+ } else if (!strcasecmp(var, "basedn")) {
+ binding->basedn = strdup(val);
} else if (!strcasecmp(var, "binddn")) {
binding->binddn = strdup(val);
} else if (!strcasecmp(var, "bindpass")) {
binding->bindpass = strdup(val);
} else if (!strcasecmp(var, "host")) {
binding->host = strdup(val);
+ } else if (!strcasecmp(var, "mech")) {
+ binding->defaults->mech = strdup(val);
+ } else if (!strcasecmp(var, "realm")) {
+ binding->defaults->realm = strdup(val);
+ } else if (!strcasecmp(var, "authcid")) {
+ binding->defaults->authcid = strdup(val);
+ } else if (!strcasecmp(var, "authzid")) {
+ binding->defaults->authzid = strdup(val);
}
+
}
- if (!binding->ldap_base || !binding->binddn || !binding->bindpass || !binding->queryfmt) {
+ if (!binding->basedn || !binding->filter) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "You must define \"base\", \"binddn\", \"bindpass\", and \"queryfmt\" in mod_xml_ldap.conf.xml\n");
+ "You must define \"basedn\", and \"filter\" in mod_xml_ldap.conf.xml\n");
continue;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s] [%s]\n",
- switch_strlen_zero(bname) ? "N/A" : bname, binding->ldap_base, binding->bindings ? binding->bindings : "all");
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s] (%s) [%s]\n",
+ switch_strlen_zero(bname) ? "N/A" : bname, binding->basedn, binding->filter, binding->bindings ? binding->bindings : "all");
switch_xml_bind_search_function(xml_ldap_search, switch_xml_parse_section_string(bname), binding);
1
0