mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 16:15:04 +00:00
add zerconf (the howl depend lib needs work sigh)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@606 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
55baa5c0d6
commit
176908397b
@ -12,7 +12,7 @@ AM_LDFLAGS = -L$(PREFIX)/lib
|
|||||||
AM_LDFLAGS += $(shell $(APR_CONFIG) --link-ld --libs )
|
AM_LDFLAGS += $(shell $(APR_CONFIG) --link-ld --libs )
|
||||||
AM_CFLAGS += $(shell $(APU_CONFIG) --includes)
|
AM_CFLAGS += $(shell $(APU_CONFIG) --includes)
|
||||||
AM_LDFLAGS += $(shell $(APU_CONFIG) --link-ld --libs ) -lsqlite3
|
AM_LDFLAGS += $(shell $(APU_CONFIG) --link-ld --libs ) -lsqlite3
|
||||||
AM_LDFLAGS += -lhowl -lresample -lm -L/usr/local/lib/db42 -L/usr/local/lib
|
AM_LDFLAGS += -lresample -lm -L/usr/local/lib/db42 -L/usr/local/lib
|
||||||
OSARCH=$(shell uname -s)
|
OSARCH=$(shell uname -s)
|
||||||
if ISLINUX
|
if ISLINUX
|
||||||
AM_LDFLAGS += -Wl,-E
|
AM_LDFLAGS += -Wl,-E
|
||||||
@ -131,7 +131,6 @@ depends:
|
|||||||
./build/buildlib.sh . install apr-1.2.2.tar.gz --prefix=$(PREFIX)
|
./build/buildlib.sh . install apr-1.2.2.tar.gz --prefix=$(PREFIX)
|
||||||
./build/buildlib.sh . install apr-util-1.2.2.tar.gz --with-apr=../apr-1.2.2 --prefix=$(PREFIX)
|
./build/buildlib.sh . install apr-util-1.2.2.tar.gz --with-apr=../apr-1.2.2 --prefix=$(PREFIX)
|
||||||
./build/buildlib.sh . libresample-0.1.3.tgz --prefix=$(PREFIX)
|
./build/buildlib.sh . libresample-0.1.3.tgz --prefix=$(PREFIX)
|
||||||
./build/buildlib.sh . howl-1.0.0.tar.gz --prefix=$(PREFIX)
|
|
||||||
rm build/freeswitch.env
|
rm build/freeswitch.env
|
||||||
|
|
||||||
|
|
||||||
|
@ -245,9 +245,8 @@ AM_CFLAGS = -I$(PREFIX)/include $(shell $(APR_CONFIG) --cflags \
|
|||||||
-DSWITCH_CONF_DIR=\"$(PREFIX)/conf\" \
|
-DSWITCH_CONF_DIR=\"$(PREFIX)/conf\" \
|
||||||
-DSWITCH_DB_DIR=\"$(PREFIX)/db\"
|
-DSWITCH_DB_DIR=\"$(PREFIX)/db\"
|
||||||
AM_LDFLAGS = -L$(PREFIX)/lib $(shell $(APR_CONFIG) --link-ld --libs ) \
|
AM_LDFLAGS = -L$(PREFIX)/lib $(shell $(APR_CONFIG) --link-ld --libs ) \
|
||||||
$(shell $(APU_CONFIG) --link-ld --libs ) -lsqlite3 -lhowl \
|
$(shell $(APU_CONFIG) --link-ld --libs ) -lsqlite3 -lresample \
|
||||||
-lresample -lm -L/usr/local/lib/db42 -L/usr/local/lib \
|
-lm -L/usr/local/lib/db42 -L/usr/local/lib $(am__append_1)
|
||||||
$(am__append_1)
|
|
||||||
OSARCH = $(shell uname -s)
|
OSARCH = $(shell uname -s)
|
||||||
@ISMAC_FALSE@SOLINK = -shared -Xlinker -x
|
@ISMAC_FALSE@SOLINK = -shared -Xlinker -x
|
||||||
@ISMAC_TRUE@SOLINK = -dynamic -bundle -undefined suppress -force_flat_namespace
|
@ISMAC_TRUE@SOLINK = -dynamic -bundle -undefined suppress -force_flat_namespace
|
||||||
@ -1008,7 +1007,6 @@ depends:
|
|||||||
./build/buildlib.sh . install apr-1.2.2.tar.gz --prefix=$(PREFIX)
|
./build/buildlib.sh . install apr-1.2.2.tar.gz --prefix=$(PREFIX)
|
||||||
./build/buildlib.sh . install apr-util-1.2.2.tar.gz --with-apr=../apr-1.2.2 --prefix=$(PREFIX)
|
./build/buildlib.sh . install apr-util-1.2.2.tar.gz --with-apr=../apr-1.2.2 --prefix=$(PREFIX)
|
||||||
./build/buildlib.sh . libresample-0.1.3.tgz --prefix=$(PREFIX)
|
./build/buildlib.sh . libresample-0.1.3.tgz --prefix=$(PREFIX)
|
||||||
./build/buildlib.sh . howl-1.0.0.tar.gz --prefix=$(PREFIX)
|
|
||||||
rm build/freeswitch.env
|
rm build/freeswitch.env
|
||||||
|
|
||||||
modules: $(NAME)
|
modules: $(NAME)
|
||||||
|
6
conf/zeroconf.conf
Normal file
6
conf/zeroconf.conf
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[settings]
|
||||||
|
|
||||||
|
; cant do both at once WTF?
|
||||||
|
publish => yes
|
||||||
|
#browse => _sip._udp
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
|
event_handlers/mod_zeroconf
|
||||||
applications/mod_bridgecall
|
applications/mod_bridgecall
|
||||||
applications/mod_playback
|
applications/mod_playback
|
||||||
applications/mod_ivrtest
|
applications/mod_ivrtest
|
||||||
@ -20,3 +21,4 @@ timers/mod_softtimer
|
|||||||
dialplans/mod_pcre
|
dialplans/mod_pcre
|
||||||
directories/mod_ldap
|
directories/mod_ldap
|
||||||
dialplans/mod_dialplan_directory
|
dialplans/mod_dialplan_directory
|
||||||
|
|
||||||
|
@ -330,6 +330,8 @@ typedef enum {
|
|||||||
SWITCH_EVENT_OUTBOUND_CHAN - A new outbound channel has been created
|
SWITCH_EVENT_OUTBOUND_CHAN - A new outbound channel has been created
|
||||||
SWITCH_EVENT_STARTUP - The system has been started
|
SWITCH_EVENT_STARTUP - The system has been started
|
||||||
SWITCH_EVENT_SHUTDOWN - The system has been shutdown
|
SWITCH_EVENT_SHUTDOWN - The system has been shutdown
|
||||||
|
SWITCH_EVENT_PUBLISH - Publish
|
||||||
|
SWITCH_EVENT_UNPUBLISH - UnPublish
|
||||||
SWITCH_EVENT_ALL - All events at once
|
SWITCH_EVENT_ALL - All events at once
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
@ -345,6 +347,8 @@ typedef enum {
|
|||||||
SWITCH_EVENT_OUTBOUND_CHAN,
|
SWITCH_EVENT_OUTBOUND_CHAN,
|
||||||
SWITCH_EVENT_STARTUP,
|
SWITCH_EVENT_STARTUP,
|
||||||
SWITCH_EVENT_SHUTDOWN,
|
SWITCH_EVENT_SHUTDOWN,
|
||||||
|
SWITCH_EVENT_PUBLISH,
|
||||||
|
SWITCH_EVENT_UNPUBLISH,
|
||||||
SWITCH_EVENT_ALL
|
SWITCH_EVENT_ALL
|
||||||
} switch_event_t;
|
} switch_event_t;
|
||||||
|
|
||||||
|
@ -1326,6 +1326,7 @@ static int config_exosip(int reload)
|
|||||||
SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
||||||
{
|
{
|
||||||
eXosip_event_t *event = NULL;
|
eXosip_event_t *event = NULL;
|
||||||
|
switch_event *s_event;
|
||||||
|
|
||||||
config_exosip(0);
|
config_exosip(0);
|
||||||
|
|
||||||
@ -1339,6 +1340,12 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||||||
return SWITCH_STATUS_TERM;
|
return SWITCH_STATUS_TERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (switch_event_create(&s_event, SWITCH_EVENT_PUBLISH) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_sip._udp");
|
||||||
|
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "port", "%d", globals.port);
|
||||||
|
switch_event_fire(&s_event);
|
||||||
|
}
|
||||||
|
|
||||||
globals.running = 1;
|
globals.running = 1;
|
||||||
while (globals.running > 0) {
|
while (globals.running > 0) {
|
||||||
if (!(event = eXosip_event_wait(0, 100))) {
|
if (!(event = eXosip_event_wait(0, 100))) {
|
||||||
|
19
src/mod/event_handlers/mod_zeroconf/Makefile
Normal file
19
src/mod/event_handlers/mod_zeroconf/Makefile
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
LDFLAGS += -lhowl
|
||||||
|
CFLAGS += -I$(PREFIX)/include/howl
|
||||||
|
LINKER=$(CC)
|
||||||
|
|
||||||
|
|
||||||
|
all: depends $(MODNAME).so
|
||||||
|
|
||||||
|
depends:
|
||||||
|
$(BASE)/build/buildlib.sh $(BASE) install howl-1.0.0.tar.gz --prefix=$(PREFIX)
|
||||||
|
|
||||||
|
$(MODNAME).so: $(MODNAME).c
|
||||||
|
$(CC) $(CFLAGS) -fPIC -c $(MODNAME).c -o $(MODNAME).o
|
||||||
|
$(LINKER) $(SOLINK) -o $(MODNAME).so $(MODNAME).o $(LDFLAGS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -fr *.so *.o *~
|
||||||
|
|
||||||
|
install:
|
||||||
|
cp -f $(MODNAME).so $(PREFIX)/mod
|
319
src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c
Normal file
319
src/mod/event_handlers/mod_zeroconf/mod_zeroconf.c
Normal file
@ -0,0 +1,319 @@
|
|||||||
|
/*
|
||||||
|
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||||
|
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
|
||||||
|
*
|
||||||
|
* Version: MPL 1.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Anthony Minessale II <anthmct@yahoo.com>
|
||||||
|
* Portions created by the Initial Developer are Copyright (C)
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*
|
||||||
|
* Anthony Minessale II <anthmct@yahoo.com>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* mod_zeroconf.c -- Framework Demo Module
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <switch.h>
|
||||||
|
#include <howl.h>
|
||||||
|
|
||||||
|
static const char modname[] = "mod_zeroconf";
|
||||||
|
|
||||||
|
static switch_memory_pool *module_pool;
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
sw_discovery discovery;
|
||||||
|
sw_discovery_publish_id disc_id;
|
||||||
|
switch_mutex_t *zc_lock;
|
||||||
|
} globals;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static sw_result HOWL_API my_browser(sw_discovery discovery,
|
||||||
|
sw_discovery_oid oid,
|
||||||
|
sw_discovery_browse_status status,
|
||||||
|
sw_uint32 interface_index,
|
||||||
|
sw_const_string name,
|
||||||
|
sw_const_string type,
|
||||||
|
sw_const_string domain,
|
||||||
|
sw_opaque_t extra) {
|
||||||
|
sw_discovery_resolve_id rid;
|
||||||
|
|
||||||
|
switch (status) {
|
||||||
|
case SW_DISCOVERY_BROWSE_INVALID:
|
||||||
|
{
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "browse reply: Invalid\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SW_DISCOVERY_BROWSE_RELEASE:
|
||||||
|
{
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "browse reply: Release\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SW_DISCOVERY_BROWSE_ADD_DOMAIN:
|
||||||
|
{
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "browse reply: Add Domain\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SW_DISCOVERY_BROWSE_ADD_DEFAULT_DOMAIN:
|
||||||
|
{
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "browse reply: Add Default Domain\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SW_DISCOVERY_BROWSE_REMOVE_DOMAIN:
|
||||||
|
{
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "browse reply: Remove Domain\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SW_DISCOVERY_BROWSE_REMOVE_SERVICE:
|
||||||
|
{
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "browse reply: Remove Service\n");
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "remove service: 0x%x %s %s %s\n", interface_index, name, type, domain);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SW_DISCOVERY_BROWSE_RESOLVED:
|
||||||
|
{
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "browse reply: Resolved\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SW_DISCOVERY_BROWSE_ADD_SERVICE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SW_OKAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static sw_result HOWL_API my_service_reply(sw_discovery discovery,
|
||||||
|
sw_discovery_oid oid,
|
||||||
|
sw_discovery_publish_status status,
|
||||||
|
sw_opaque extra) {
|
||||||
|
static sw_string status_text[] = {
|
||||||
|
"Started",
|
||||||
|
"Stopped",
|
||||||
|
"Name Collision",
|
||||||
|
"Invalid"
|
||||||
|
};
|
||||||
|
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "publish reply: %s\n", status_text[status]);
|
||||||
|
return SW_OKAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void event_handler(switch_event *event)
|
||||||
|
{
|
||||||
|
sw_text_record text_record;
|
||||||
|
sw_result result;
|
||||||
|
|
||||||
|
switch (event->event_id) {
|
||||||
|
case SWITCH_EVENT_PUBLISH:
|
||||||
|
if (sw_text_record_init(&text_record) != SW_OKAY) {
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "sw_text_record_init() failed\n");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
switch_event_header *hp;
|
||||||
|
char *service = switch_event_get_header(event, "service");
|
||||||
|
char *port = switch_event_get_header(event, "port");
|
||||||
|
int porti = 0;
|
||||||
|
for (hp = event->headers; hp; hp = hp->next) {
|
||||||
|
int len = strlen(hp->name) + strlen(hp->value) + 2;
|
||||||
|
char *data = malloc(len);
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(data, len, "%s=%s", hp->name, hp->value);
|
||||||
|
if (sw_text_record_add_string(text_record, data) != SW_OKAY) {
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "unable to add service text: %s\n", data);
|
||||||
|
free(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
if (!service) {
|
||||||
|
service = "_freeswitch._tcp";
|
||||||
|
}
|
||||||
|
if (port) {
|
||||||
|
porti = atoi(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_mutex_lock(globals.zc_lock);
|
||||||
|
if ((result = sw_discovery_publish(globals.discovery,
|
||||||
|
0,
|
||||||
|
"freeswitch",
|
||||||
|
service,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
porti,
|
||||||
|
sw_text_record_bytes(text_record),
|
||||||
|
sw_text_record_len(text_record),
|
||||||
|
my_service_reply,
|
||||||
|
NULL,
|
||||||
|
&globals.disc_id)) != SW_OKAY) {
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "publish failed: %d\n", result);
|
||||||
|
sw_text_record_fina(text_record);
|
||||||
|
switch_mutex_unlock(globals.zc_lock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch_mutex_unlock(globals.zc_lock);
|
||||||
|
sw_text_record_fina(text_record);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SWITCH_EVENT_UNPUBLISH:
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static switch_status load_config(void)
|
||||||
|
{
|
||||||
|
switch_config cfg;
|
||||||
|
switch_status status = SWITCH_STATUS_SUCCESS;
|
||||||
|
char *var, *val;
|
||||||
|
char *cf = "zeroconf.conf";
|
||||||
|
int count = 0;
|
||||||
|
sw_discovery_oid *oid;
|
||||||
|
|
||||||
|
if (!switch_config_open_file(&cfg, cf)) {
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "open of %s failed\n", cf);
|
||||||
|
return SWITCH_STATUS_TERM;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (switch_config_next_pair(&cfg, &var, &val)) {
|
||||||
|
if (!strcasecmp(cfg.category, "settings")) {
|
||||||
|
if (!strcmp(var, "browse")) {
|
||||||
|
if ((oid = switch_core_alloc(module_pool, sizeof(*oid)))) {
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Bind browser to to %s\n", val);
|
||||||
|
switch_mutex_lock(globals.zc_lock);
|
||||||
|
sw_discovery_browse(globals.discovery, 0, val, NULL, my_browser, NULL, oid);
|
||||||
|
switch_mutex_unlock(globals.zc_lock);
|
||||||
|
count++;
|
||||||
|
} else {
|
||||||
|
return SWITCH_STATUS_MEMERR;
|
||||||
|
}
|
||||||
|
} else if (!strcasecmp(var, "publish") && !strcasecmp(val, "yes")) {
|
||||||
|
if (switch_event_bind((char *) modname, SWITCH_EVENT_PUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
|
||||||
|
SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Couldn't bind!\n");
|
||||||
|
return SWITCH_STATUS_GENERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (switch_event_bind((char *) modname, SWITCH_EVENT_UNPUBLISH, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) !=
|
||||||
|
SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Couldn't bind!\n");
|
||||||
|
return SWITCH_STATUS_GENERR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_config_close_file(&cfg);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static switch_loadable_module_interface zeroconf_module_interface = {
|
||||||
|
/*.module_name */ modname,
|
||||||
|
/*.endpoint_interface */ NULL,
|
||||||
|
/*.timer_interface */ NULL,
|
||||||
|
/*.dialplan_interface */ NULL,
|
||||||
|
/*.codec_interface */ NULL,
|
||||||
|
/*.application_interface */ NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MY_EVENT_PUBLISH "zeroconf::broadcast"
|
||||||
|
#define MY_EVENT_UNPUBLISH "zeroconf::unbroadcast"
|
||||||
|
|
||||||
|
static int RUNNING = 0;
|
||||||
|
|
||||||
|
SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
|
||||||
|
{
|
||||||
|
if (RUNNING == 1) {
|
||||||
|
RUNNING = -1;
|
||||||
|
switch_yield(100000);
|
||||||
|
}
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SWITCH_MOD_DECLARE(switch_status) switch_module_load(switch_loadable_module_interface **interface, char *filename)
|
||||||
|
{
|
||||||
|
|
||||||
|
memset(&globals, 0, sizeof(globals));
|
||||||
|
|
||||||
|
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OH OH no pool\n");
|
||||||
|
return SWITCH_STATUS_TERM;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_mutex_init(&globals.zc_lock, SWITCH_MUTEX_NESTED, module_pool);
|
||||||
|
|
||||||
|
if (sw_discovery_init(&globals.discovery) != SW_OKAY) {
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "sw_discovery_init() failed\n");
|
||||||
|
return SWITCH_STATUS_TERM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (load_config() != SWITCH_STATUS_SUCCESS) {
|
||||||
|
return SWITCH_STATUS_TERM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (switch_event_reserve_subclass(MY_EVENT_PUBLISH) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Couldn't register subclass!");
|
||||||
|
return SWITCH_STATUS_GENERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (switch_event_reserve_subclass(MY_EVENT_UNPUBLISH) != SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Couldn't register subclass!");
|
||||||
|
return SWITCH_STATUS_GENERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* connect my internal structure to the blank pointer passed to me */
|
||||||
|
*interface = &zeroconf_module_interface;
|
||||||
|
|
||||||
|
/* indicate that the module should continue to be loaded */
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
RUNNING = 1;
|
||||||
|
while(RUNNING == 1) {
|
||||||
|
unsigned int ms;
|
||||||
|
ms = 100;
|
||||||
|
sw_discovery_step(globals.discovery, &ms);
|
||||||
|
switch_yield(1000);
|
||||||
|
}
|
||||||
|
RUNNING = 0;
|
||||||
|
return SWITCH_STATUS_TERM;
|
||||||
|
}
|
207
src/mod/event_handlers/mod_zeroconf/mod_zeroconf.vcproj
Normal file
207
src/mod/event_handlers/mod_zeroconf/mod_zeroconf.vcproj
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="8.00"
|
||||||
|
Name="mod_zeroconf"
|
||||||
|
ProjectGUID="{3A2A7795-C216-4FFF-B8EF-4D17A84BACCC}"
|
||||||
|
RootNamespace="mod_zeroconf"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="Debug"
|
||||||
|
IntermediateDirectory="Debug"
|
||||||
|
ConfigurationType="2"
|
||||||
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories=""$(InputDir)..\..\..\include";"$(InputDir)include";"$(InputDir)..\..\..\..\libs\include""
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="1"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_zeroconf.dll"
|
||||||
|
LinkIncremental="2"
|
||||||
|
AdditionalLibraryDirectories="$(InputDir)..\..\..\libs\apr\Debug"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/mod_zeroconf.pdb"
|
||||||
|
SubSystem="2"
|
||||||
|
ImportLibrary="$(OutDir)/mod_zeroconf.lib"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="Release"
|
||||||
|
IntermediateDirectory="Release"
|
||||||
|
ConfigurationType="2"
|
||||||
|
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||||
|
CharacterSet="2"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories=""$(InputDir)..\..\..\include";"$(InputDir)include";"$(InputDir)..\..\..\..\libs\include""
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MOD_EXPORTS"
|
||||||
|
RuntimeLibrary="0"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="..\..\..\..\w32\vsnet\$(OutDir)/mod/mod_zeroconf.dll"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories=""$(InputDir)..\..\..\libs\apr\Release""
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="2"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
ImportLibrary="$(OutDir)/mod_zeroconf.lib"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\mod_zeroconf.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource Files"
|
||||||
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||||
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
@ -98,6 +98,8 @@ static char *EVENT_NAMES[] = {
|
|||||||
"OUTBOUND_CHAN",
|
"OUTBOUND_CHAN",
|
||||||
"STARTUP",
|
"STARTUP",
|
||||||
"SHUTDOWN",
|
"SHUTDOWN",
|
||||||
|
"PUBLISH",
|
||||||
|
"UNPUBLISH",
|
||||||
"ALL"
|
"ALL"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -116,6 +118,7 @@ static int switch_events_match(switch_event *event, switch_event_node *node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (match || event->event_id == node->event_id) {
|
if (match || event->event_id == node->event_id) {
|
||||||
|
|
||||||
if (event->subclass && node->subclass) {
|
if (event->subclass && node->subclass) {
|
||||||
if (!strncasecmp(node->subclass->name, "file:", 5)) {
|
if (!strncasecmp(node->subclass->name, "file:", 5)) {
|
||||||
char *file_header;
|
char *file_header;
|
||||||
@ -130,7 +133,7 @@ static int switch_events_match(switch_event *event, switch_event_node *node)
|
|||||||
} else {
|
} else {
|
||||||
match = strstr(event->subclass->name, node->subclass->name) ? 1 : 0;
|
match = strstr(event->subclass->name, node->subclass->name) ? 1 : 0;
|
||||||
}
|
}
|
||||||
} else if (event->subclass && !node->subclass) {
|
} else if ((event->subclass && !node->subclass) || (!event->subclass && !node->subclass)) {
|
||||||
match = 1;
|
match = 1;
|
||||||
} else {
|
} else {
|
||||||
match = 0;
|
match = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user