diff --git a/daemon/Makefile b/daemon/Makefile index 25d9c9a44..9828f8939 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -1,4 +1,3 @@ -CC?=gcc CFLAGS= -g -Wall -pthread -fno-strict-aliasing CFLAGS+= -std=c99 CFLAGS+= `pkg-config --cflags glib-2.0` @@ -10,38 +9,13 @@ CFLAGS+= `pcre-config --cflags` CFLAGS+= -I. -I../kernel-module/ -I../lib/ CFLAGS+= -D_GNU_SOURCE -ifeq ($(RTPENGINE_VERSION),) - DPKG_PRSCHNGLG= $(shell which dpkg-parsechangelog 2>/dev/null) - ifneq ($(DPKG_PRSCHNGLG),) - DPKG_PRSCHNGLG=$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}') - endif - GIT_BR_COMMIT=$(shell git branch --no-color --no-column -v 2> /dev/null | awk '/^\*/ {OFS="-"; print "git", $$2, $$3}') - - ifneq ($(DPKG_PRSCHNGLG),) - RTPENGINE_VERSION+=$(DPKG_PRSCHNGLG) - endif - ifneq ($(GIT_BR_COMMIT),) - RTPENGINE_VERSION+=$(GIT_BR_COMMIT) - endif - - ifeq ($(RTPENGINE_VERSION),) - RTPENGINE_VERSION+=undefined - endif -endif -CFLAGS+= -DRTPENGINE_VERSION="\"$(RTPENGINE_VERSION)\"" - CFLAGS+= -DRE_PLUGIN_DIR="\"/usr/lib/rtpengine\"" +### compile time options: #CFLAGS+= -DSRTCP_KEY_DERIVATION_RFC_COMPLIANCE #CFLAGS+= -DTERMINATE_SDP_AT_BLANK_LINE #CFLAGS+= -DSTRICT_SDES_KEY_LIFETIME -ifeq ($(DBG),yes) -CFLAGS+= -D__DEBUG=1 -else -CFLAGS+= -O3 -endif - LDFLAGS= -lm LDFLAGS+= `pkg-config --libs glib-2.0` LDFLAGS+= `pkg-config --libs gthread-2.0` @@ -55,15 +29,7 @@ LDFLAGS+= `pcre-config --libs` LDFLAGS+= `xmlrpc-c-config client --libs` LDFLAGS+= -lhiredis -ifneq ($(DBG),yes) - DPKG_BLDFLGS= $(shell which dpkg-buildflags 2>/dev/null) - ifneq ($(DPKG_BLDFLGS),) - # support http://wiki.debian.org/Hardening for >=wheezy - CFLAGS+= `dpkg-buildflags --get CFLAGS` - CPPFLAGS+= `dpkg-buildflags --get CPPFLAGS` - LDFLAGS+= `dpkg-buildflags --get LDFLAGS` - endif -endif +include ../lib/lib.Makefile SRCS= main.c kernel.c poller.c aux.c control_tcp.c streambuf.c call.c control_udp.c redis.c \ bencode.c cookie_cache.c udp_listener.c control_ng.c sdp.c str.c stun.c rtcp.c \ diff --git a/daemon/main.c b/daemon/main.c index 95fc70f12..95ca595f1 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -35,13 +35,6 @@ -#define die(x...) do { \ - ilog(LOG_CRIT, x); \ - exit(-1); \ -} while(0) - - - struct main_context { struct poller *p; struct callmaster *m; @@ -52,8 +45,6 @@ struct main_context { static mutex_t *openssl_locks; -static char *pidfile; -static gboolean foreground; static GQueue interfaces = G_QUEUE_INIT; static GQueue keyspaces = G_QUEUE_INIT; static endpoint_t tcp_listen_ep; @@ -265,8 +256,6 @@ static int redis_ep_parse(endpoint_t *ep, int *db, char **auth, const char *auth static void options(int *argc, char ***argv) { - char *configfile = NULL; - char *configsection = "rtpengine"; char **if_a = NULL; char **ks_a = NULL; unsigned int uint_keyspace_db; @@ -284,16 +273,12 @@ static void options(int *argc, char ***argv) { char *log_facility_s = NULL; char *log_facility_cdr_s = NULL; char *log_facility_rtcp_s = NULL; - int version = 0; int sip_source = 0; char *homerp = NULL; char *homerproto = NULL; char *endptr; GOptionEntry e[] = { - { "config-file", 0, 0, G_OPTION_ARG_STRING, &configfile, "Load config from this file", "FILE" }, - { "config-section",0,0, G_OPTION_ARG_STRING, &configsection, "Config file section to use", "STRING" }, - { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Print build time and exit", NULL }, { "table", 't', 0, G_OPTION_ARG_INT, &table, "Kernel table to use", "INT" }, { "no-fallback",'F', 0, G_OPTION_ARG_NONE, &no_fallback, "Only start when kernel module is available", NULL }, { "interface", 'i', 0, G_OPTION_ARG_STRING_ARRAY,&if_a, "Local interface for RTP", "[NAME/]IP[!IP]"}, @@ -309,8 +294,6 @@ static void options(int *argc, char ***argv) { { "timeout", 'o', 0, G_OPTION_ARG_INT, &timeout, "RTP timeout", "SECS" }, { "silent-timeout",'s',0,G_OPTION_ARG_INT, &silent_timeout,"RTP timeout for muted", "SECS" }, { "final-timeout",'a',0,G_OPTION_ARG_INT, &final_timeout, "Call timeout", "SECS" }, - { "pidfile", 'p', 0, G_OPTION_ARG_FILENAME, &pidfile, "Write PID to file", "FILE" }, - { "foreground", 'f', 0, G_OPTION_ARG_NONE, &foreground, "Don't fork to background", NULL }, { "port-min", 'm', 0, G_OPTION_ARG_INT, &port_min, "Lowest port to use for RTP", "INT" }, { "port-max", 'M', 0, G_OPTION_ARG_INT, &port_max, "Highest port to use for RTP", "INT" }, { "redis", 'r', 0, G_OPTION_ARG_STRING, &redisps, "Connect to Redis database", "[PW@]IP:PORT/INT" }, @@ -319,7 +302,6 @@ static void options(int *argc, char ***argv) { { "redis-expires", 0, 0, G_OPTION_ARG_INT, &redis_expires, "Expire time in seconds for redis keys", "INT" }, { "no-redis-required", 'q', 0, G_OPTION_ARG_NONE, &no_redis_required, "Start no matter of redis connection state", NULL }, { "b2b-url", 'b', 0, G_OPTION_ARG_STRING, &b2b_url, "XMLRPC URL of B2B UA" , "STRING" }, - { "log-level", 'L', 0, G_OPTION_ARG_INT, (void *)&log_level,"Mask log priorities above this level","INT" }, { "log-facility",0, 0, G_OPTION_ARG_STRING, &log_facility_s, "Syslog facility to use for logging", "daemon|local0|...|local7"}, { "log-facility-cdr",0, 0, G_OPTION_ARG_STRING, &log_facility_cdr_s, "Syslog facility to use for logging CDRs", "daemon|local0|...|local7"}, { "log-facility-rtcp",0, 0, G_OPTION_ARG_STRING, &log_facility_rtcp_s, "Syslog facility to use for logging RTCP", "daemon|local0|...|local7"}, @@ -339,14 +321,8 @@ static void options(int *argc, char ***argv) { { NULL, } }; - const char *errstr = config_load(argc, argv, e, " - next-generation media proxy", &configfile, - "/etc/rtpengine/rtpengine.conf", &configsection); - - if (errstr) - die("Bad command line: %s", errstr); - - if (version) - die("%s", RTPENGINE_VERSION); + config_load(argc, argv, e, " - next-generation media proxy", + "/etc/rtpengine/rtpengine.conf", "rtpengine"); if (!if_a) die("Missing option --interface"); @@ -444,21 +420,21 @@ static void options(int *argc, char ***argv) { if (log_facility_s) { if (!parse_log_facility(log_facility_s, &_log_facility)) { print_available_log_facilities(); - die ("Invalid log facility '%s' (--log-facility)\n", log_facility_s); + die ("Invalid log facility '%s' (--log-facility)", log_facility_s); } } if (log_facility_cdr_s) { if (!parse_log_facility(log_facility_cdr_s, &_log_facility_cdr)) { print_available_log_facilities(); - die ("Invalid log facility for CDR '%s' (--log-facility-cdr)\n", log_facility_cdr_s); + die ("Invalid log facility for CDR '%s' (--log-facility-cdr)", log_facility_cdr_s); } } if (log_facility_rtcp_s) { if (!parse_log_facility(log_facility_rtcp_s, &_log_facility_rtcp)) { print_available_log_facilities(); - die ("Invalid log facility for RTCP '%s' (--log-facility-rtcp)\n", log_facility_rtcp_s); + die ("Invalid log facility for RTCP '%s' (--log-facility-rtcp)n", log_facility_rtcp_s); } } @@ -642,9 +618,8 @@ no_kernel: ctx->m->conf = mc; - if (!foreground) - daemonize(); - wpidfile(pidfile); + daemonize(); + wpidfile(); ctx->m->homer = homer_sender_new(&homer_ep, homer_protocol, homer_id); diff --git a/lib/auxlib.c b/lib/auxlib.c index d75f5d5ad..b69853960 100644 --- a/lib/auxlib.c +++ b/lib/auxlib.c @@ -4,9 +4,20 @@ #include #include #include -#include "loglib.h" +#include +#include "log.h" + + +static const char *config_file; +static const char *config_section; +static const char *pid_file; +static int foreground; +static int version; + void daemonize(void) { + if (foreground) + return; if (fork()) _exit(0); write_log = (write_log_t *) syslog; @@ -16,23 +27,42 @@ void daemonize(void) { setpgrp(); } -void wpidfile(const char *pidfile) { +void wpidfile() { FILE *fp; - if (!pidfile) + if (!pid_file) return; - fp = fopen(pidfile, "w"); + fp = fopen(pid_file, "w"); if (fp) { fprintf(fp, "%u\n", getpid()); fclose(fp); } } + +static unsigned int options_length(const GOptionEntry *arr) { + unsigned int len = 0; + for (const GOptionEntry *p = arr; p->long_name; p++) + len++; + return len; +} + + +static const GOptionEntry shared_options[] = { + { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Print build time and exit", NULL }, + { "config-file", 0, 0, G_OPTION_ARG_STRING, &config_file, "Load config from this file", "FILE" }, + { "config-section", 0, 0, G_OPTION_ARG_STRING, &config_section,"Config file section to use", "STRING" }, + { "log-level", 'L', 0, G_OPTION_ARG_INT, (void *)&log_level,"Mask log priorities above this level","INT" }, + { "pidfile", 'p', 0, G_OPTION_ARG_FILENAME, &pid_file, "Write PID to file", "FILE" }, + { "foreground", 'f', 0, G_OPTION_ARG_NONE, &foreground, "Don't fork to background", NULL }, + { NULL, } +}; + #define CONF_OPTION_GLUE(get_func, data_type, ...) \ { \ data_type *varptr = e->arg_data; \ - data_type var = g_key_file_get_ ## get_func(kf, *section_ptr, e->long_name, \ + data_type var = g_key_file_get_ ## get_func(kf, config_section, e->long_name, \ ##__VA_ARGS__, &er); \ if (er && g_error_matches(er, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND)) { \ g_error_free(er); \ @@ -40,39 +70,49 @@ void wpidfile(const char *pidfile) { break; \ } \ if (er) \ - return er->message; \ + goto err; \ *varptr = var; \ break; \ } -const char *config_load(int *argc, char ***argv, GOptionEntry *entries, const char *description, - char **filename_ptr, const char *default_config, char **section_ptr) +void config_load(int *argc, char ***argv, GOptionEntry *app_entries, const char *description, + const char *default_config, const char *default_section) { GOptionContext *c; GError *er = NULL; - const char *config_file; + const char *use_config; int fatal = 0; int saved_argc = *argc; char **saved_argv = g_strdupv(*argv); + // prepend shared CLI options + unsigned int shared_len = options_length(shared_options); + unsigned int app_len = options_length(app_entries); + GOptionEntry *entries = malloc(sizeof(*entries) * (shared_len + app_len + 1)); + memcpy(entries, shared_options, sizeof(*entries) * shared_len); + memcpy(&entries[shared_len], app_entries, sizeof(*entries) * (app_len + 1)); + + if (!config_section) + config_section = default_section; + c = g_option_context_new(description); g_option_context_add_main_entries(c, entries, NULL); if (!g_option_context_parse(c, argc, argv, &er)) - return er->message; + goto err; // is there a config file to load? - config_file = default_config; - if (filename_ptr && *filename_ptr) { - config_file = *filename_ptr; + use_config = default_config; + if (config_file) { + use_config = config_file; fatal = 1; } GKeyFile *kf = g_key_file_new(); - if (!g_key_file_load_from_file(kf, config_file, G_KEY_FILE_NONE, &er)) { + if (!g_key_file_load_from_file(kf, use_config, G_KEY_FILE_NONE, &er)) { if (!fatal && (g_error_matches(er, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND) || g_error_matches(er, G_FILE_ERROR, G_FILE_ERROR_NOENT))) - return NULL; - return er->message; + goto out; + goto err; } // iterate the options list and see if the config file defines any @@ -99,5 +139,14 @@ const char *config_load(int *argc, char ***argv, GOptionEntry *entries, const ch // process CLI arguments again so they override options from the config file g_option_context_parse(c, &saved_argc, &saved_argv, &er); - return NULL; +out: + if (version) { + fprintf(stderr, "Version: %s\n", RTPENGINE_VERSION); + exit(0); + } + + return; + +err: + die("Bad command line: %s", er->message); } diff --git a/lib/auxlib.h b/lib/auxlib.h index 0c59cd5e8..3e29c7223 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -4,9 +4,9 @@ #include void daemonize(void); -void wpidfile(const char *pidfile); -const char *config_load(int *argc, char ***argv, GOptionEntry *entries, const char *description, - char **filename_ptr, const char *default_config, char **section_ptr); +void wpidfile(void); +void config_load(int *argc, char ***argv, GOptionEntry *entries, const char *description, + const char *default_config, const char *default_section); #endif diff --git a/lib/lib.Makefile b/lib/lib.Makefile new file mode 100644 index 000000000..7fe7de986 --- /dev/null +++ b/lib/lib.Makefile @@ -0,0 +1,40 @@ +CC ?= gcc + + +ifeq ($(RTPENGINE_VERSION),) + DPKG_PRSCHNGLG= $(shell which dpkg-parsechangelog 2>/dev/null) + ifneq ($(DPKG_PRSCHNGLG),) + DPKG_PRSCHNGLG=$(shell dpkg-parsechangelog -l../debian/changelog | awk '/^Version: / {print $$2}') + endif + GIT_BR_COMMIT=$(shell git branch --no-color --no-column -v 2> /dev/null | awk '/^\*/ {OFS="-"; print "git", $$2, $$3}') + + ifneq ($(DPKG_PRSCHNGLG),) + RTPENGINE_VERSION+=$(DPKG_PRSCHNGLG) + endif + ifneq ($(GIT_BR_COMMIT),) + RTPENGINE_VERSION+=$(GIT_BR_COMMIT) + endif + + ifeq ($(RTPENGINE_VERSION),) + RTPENGINE_VERSION+=undefined + endif +endif +CFLAGS+= -DRTPENGINE_VERSION="\"$(RTPENGINE_VERSION)\"" + + +ifeq ($(DBG),yes) +CFLAGS+= -D__DEBUG=1 +else +CFLAGS+= -O3 +endif + + +ifneq ($(DBG),yes) + DPKG_BLDFLGS= $(shell which dpkg-buildflags 2>/dev/null) + ifneq ($(DPKG_BLDFLGS),) + # support http://wiki.debian.org/Hardening for >=wheezy + CFLAGS+= `dpkg-buildflags --get CFLAGS` + CPPFLAGS+= `dpkg-buildflags --get CPPFLAGS` + LDFLAGS+= `dpkg-buildflags --get LDFLAGS` + endif +endif diff --git a/lib/loglib.h b/lib/loglib.h index c42e92403..e2239b045 100644 --- a/lib/loglib.h +++ b/lib/loglib.h @@ -56,6 +56,11 @@ INLINE int get_log_level(void) { +#define die(fmt, ...) do { ilog(LOG_CRIT, "Fatal error: " fmt, ##__VA_ARGS__); exit(-1); } while (0) +#define die_errno(msg) die("%s: %s", msg, strerror(errno)) + + + #define LOG_ERROR LOG_ERR #define LOG_WARN LOG_WARNING diff --git a/recording-daemon/Makefile b/recording-daemon/Makefile index 7251a774c..fd5bfe7d3 100644 --- a/recording-daemon/Makefile +++ b/recording-daemon/Makefile @@ -1,6 +1,5 @@ TARGET= rtpengine-recording -CC?=gcc CFLAGS= -g -Wall -pthread -I. -I../lib/ CFLAGS+= -std=c99 CFLAGS+= -D_GNU_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE @@ -11,12 +10,6 @@ CFLAGS+= `pkg-config --cflags libavcodec` CFLAGS+= `pkg-config --cflags libavformat` CFLAGS+= `pkg-config --cflags libavutil` -ifeq ($(DBG),yes) -CFLAGS+= -D__DEBUG=1 -else -CFLAGS+= -O3 -endif - LDFLAGS= -lm LDFLAGS+= `pkg-config --libs glib-2.0` LDFLAGS+= `pkg-config --libs gthread-2.0` @@ -25,15 +18,7 @@ LDFLAGS+= `pkg-config --libs libavcodec` LDFLAGS+= `pkg-config --libs libavformat` LDFLAGS+= `pkg-config --libs libavutil` -ifneq ($(DBG),yes) - DPKG_BLDFLGS= $(shell which dpkg-buildflags 2>/dev/null) - ifneq ($(DPKG_BLDFLGS),) - # support http://wiki.debian.org/Hardening for >=wheezy - CFLAGS+= `dpkg-buildflags --get CFLAGS` - CPPFLAGS+= `dpkg-buildflags --get CPPFLAGS` - LDFLAGS+= `dpkg-buildflags --get LDFLAGS` - endif -endif +include ../lib/lib.Makefile SRCS= epoll.c garbage.c inotify.c main.c metafile.c stream.c recaux.c rtplib.c packet.c \ decoder.c loglib.c auxlib.c diff --git a/recording-daemon/inotify.c b/recording-daemon/inotify.c index f7f728d30..36af9017f 100644 --- a/recording-daemon/inotify.c +++ b/recording-daemon/inotify.c @@ -65,7 +65,7 @@ void inotify_setup(void) { if (inotify_fd == -1) die_errno("inotify_init1 failed"); - int ret = inotify_add_watch(inotify_fd, SPOOL_DIR, IN_CLOSE_WRITE | IN_DELETE); + int ret = inotify_add_watch(inotify_fd, spool_dir, IN_CLOSE_WRITE | IN_DELETE); if (ret == -1) die_errno("inotify_add_watch failed"); diff --git a/recording-daemon/log.h b/recording-daemon/log.h index 426ec4ad2..0a5f6a35a 100644 --- a/recording-daemon/log.h +++ b/recording-daemon/log.h @@ -8,8 +8,6 @@ #include #include -#define die(fmt, ...) do { ilog(LOG_CRIT, "Fatal error: " fmt, ##__VA_ARGS__); exit(-1); } while (0) -#define die_errno(msg) die("%s: %s", msg, strerror(errno)) #define __ilog(...) __ilog_np(__VA_ARGS__) #define dbg(fmt, ...) ilog(LOG_DEBUG, fmt, ##__VA_ARGS__) diff --git a/recording-daemon/main.c b/recording-daemon/main.c index e7f10d510..e1757033e 100644 --- a/recording-daemon/main.c +++ b/recording-daemon/main.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include "log.h" #include "epoll.h" #include "inotify.h" @@ -18,6 +20,12 @@ +int ktable = 0; +int num_threads = 8; +const char *spool_dir = "/var/spool/rtpengine"; +const char *output_dir = "/var/lib/rtpengine-recording"; + + static GQueue threads = G_QUEUE_INIT; // only accessed from main thread volatile int shutdown_flag; @@ -51,6 +59,12 @@ static void setup(void) { inotify_setup(); av_log_set_callback(avlog_ilog); openlog("rtpengine-recording", LOG_PID | LOG_NDELAY, LOG_DAEMON); + + if (!g_file_test(output_dir, G_FILE_TEST_IS_DIR)) { + ilog(LOG_INFO, "Creating output dir '%s'", output_dir); + if (mkdir(output_dir, 0700)) + die_errno("Failed to create output dir '%s'"); + } } @@ -104,12 +118,27 @@ static void cleanup(void) { } -int main() { +static void options(int *argc, char ***argv) { + GOptionEntry e[] = { + { "table", 't', 0, G_OPTION_ARG_INT, &ktable, "Kernel table rtpengine uses", "INT" }, + { "spool-dir", 0, 0, G_OPTION_ARG_STRING, &spool_dir, "Directory containing rtpengine metadata files", "PATH" }, + { "output-dir", 0, 0, G_OPTION_ARG_STRING, &output_dir, "Where to write media files to", "PATH" }, + { "num-threads", 0, 0, G_OPTION_ARG_INT, &num_threads, "Number of worker threads", "INT" }, + { NULL, } + }; + + config_load(argc, argv, e, " - rtpengine recording daemon", + "/etc/rtpengine/rtpengine-recording.conf", "rtpengine-recording"); +} + + +int main(int argc, char **argv) { + options(&argc, &argv); setup(); daemonize(); - //wpidfile(); + wpidfile(); - for (int i = 0; i < NUM_THREADS; i++) + for (int i = 0; i < num_threads; i++) start_poller_thread(); wait_for_signal(); diff --git a/recording-daemon/main.h b/recording-daemon/main.h index a25ee1974..c58659d31 100644 --- a/recording-daemon/main.h +++ b/recording-daemon/main.h @@ -2,10 +2,10 @@ #define _MAIN_H_ -#define SPOOL_DIR "/var/spool/rtpengine" -#define PROC_DIR "/proc/rtpengine/0/calls" -#define NUM_THREADS 8 - +extern int ktable; +extern int num_threads; +extern const char *spool_dir; +extern const char *output_dir; extern volatile int shutdown_flag; diff --git a/recording-daemon/metafile.c b/recording-daemon/metafile.c index c3c660e89..a7556b9e8 100644 --- a/recording-daemon/metafile.c +++ b/recording-daemon/metafile.c @@ -129,7 +129,7 @@ void metafile_change(char *name) { metafile_t *mf = metafile_get(name); char fnbuf[PATH_MAX]; - snprintf(fnbuf, sizeof(fnbuf), "%s/%s", SPOOL_DIR, name); + snprintf(fnbuf, sizeof(fnbuf), "%s/%s", spool_dir, name); // open file and seek to last known position int fd = open(fnbuf, O_RDONLY); diff --git a/recording-daemon/packet.c b/recording-daemon/packet.c index 48e221222..c0d476648 100644 --- a/recording-daemon/packet.c +++ b/recording-daemon/packet.c @@ -10,6 +10,7 @@ #include "str.h" #include "decoder.h" #include "rtcplib.h" +#include "main.h" static int ptr_cmp(const void *a, const void *b, void *dummy) { @@ -55,7 +56,7 @@ static ssrc_t *ssrc_get(metafile_t *mf, unsigned long ssrc) { ret->seq = -1; char buf[256]; - snprintf(buf, sizeof(buf), "%s-%08lx.wav", mf->parent, ssrc); + snprintf(buf, sizeof(buf), "%s/%s-%08lx.wav", output_dir, mf->parent, ssrc); ret->output = output_new(buf); g_hash_table_insert(mf->ssrc_hash, GUINT_TO_POINTER(ssrc), ret); diff --git a/recording-daemon/stream.c b/recording-daemon/stream.c index 0ae9ab2b7..974de11a0 100644 --- a/recording-daemon/stream.c +++ b/recording-daemon/stream.c @@ -97,7 +97,7 @@ void stream_open(metafile_t *mf, unsigned long id, char *name) { stream->name = g_string_chunk_insert(mf->gsc, name); char fnbuf[PATH_MAX]; - snprintf(fnbuf, sizeof(fnbuf), "%s/%s/%s", PROC_DIR, mf->parent, name); + snprintf(fnbuf, sizeof(fnbuf), "/proc/rtpengine/%u/calls/%s/%s", ktable, mf->parent, name); stream->fd = open(fnbuf, O_RDONLY | O_NONBLOCK); if (stream->fd == -1) {