-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Antonio Paunovic <[email protected]>
- Loading branch information
Antonio Paunovic
committed
Jan 20, 2017
0 parents
commit 92769fc
Showing
10 changed files
with
1,320 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6) | ||
|
||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/") | ||
set(CMAKE_INSTALL_LIBDIR "/usr/lib") | ||
|
||
project(sysrepo-plugin-dt-sip) | ||
|
||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build) # | ||
|
||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) | ||
set(CMAKE_C_FLAGS "-std=gnu99") | ||
set(SOURCES | ||
src/sip.c) | ||
|
||
if(CMAKE_BUILD_TYPE MATCHES "debug") | ||
add_executable(${CMAKE_PROJECT_NAME} ${SOURCES}) | ||
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE DEBUG=1) | ||
install(TARGETS ${CMAKE_PROJECT_NAME} | ||
DESTINATION lib/sysrepo/plugins) | ||
else() | ||
add_library(${CMAKE_PROJECT_NAME} MODULE ${SOURCES}) | ||
install(TARGETS ${CMAKE_PROJECT_NAME} LIBRARY | ||
DESTINATION lib/sysrepo/plugins) | ||
endif() | ||
|
||
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${CMAKE_PROJECT_NAME} PREFIX "") | ||
|
||
find_package(LIBUBOX REQUIRED) | ||
include_directories(${LIBUBOX_INCLUDE_DIR}) | ||
target_link_libraries(${CMAKE_PROJECT_NAME} ${LIBUBOX_LIBRARIES}) | ||
|
||
find_package(UCI REQUIRED) | ||
include_directories(${UCI_INCLUDE_DIR}) | ||
target_link_libraries(${CMAKE_PROJECT_NAME} ${UCI_LIBRARIES}) | ||
|
||
find_package(SYSREPO REQUIRED) | ||
target_link_libraries(${CMAKE_PROJECT_NAME} ${SYSREPO_LIBRARIES}) | ||
include_directories(${SYSREPO_INCLUDE_DIRS}) | ||
|
||
install( | ||
FILES | ||
yang/[email protected] | ||
DESTINATION etc/yang/ | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# LIBUBOX_FOUND - true if library and headers were found | ||
# LIBUBOX_INCLUDE_DIRS - include directories | ||
# LIBUBOX_LIBRARIES - library directories | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(PC_LIBUBOX QUIET libubox) | ||
|
||
find_path(LIBUBOX_INCLUDE_DIR libubox/uloop.h | ||
HINTS ${PC_LIBUBOX_INCLUDEDIR} ${PC_LIBUBOX_INCLUDE_DIRS} PATH_SUFFIXES libubox) | ||
|
||
find_library(LIBUBOX_LIBRARY_ubox NAMES ubox | ||
HINTS ${PC_LIBUBOX_LIBDIR} ${PC_LIBUBOX_LIBRARY_DIRS}) | ||
|
||
find_library(LIBUBOX_LIBRARY_blobmsg_json NAMES blobmsg_json | ||
HINTS ${PC_LIBUBOX_LIBDIR} ${PC_LIBUBOX_LIBRARY_DIRS}) | ||
|
||
set(LIBUBOX_LIBRARIES ${LIBUBOX_LIBRARY_ubox} ${LIBUBOX_LIBRARY_blobmsg_json}) | ||
set(LIBUBOX_INCLUDE_DIRS ${LIBUBOX_INCLUDE_DIR}) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
find_package_handle_standard_args(LIBUBOX DEFAULT_MSG LIBUBOX_LIBRARY_ubox LIBUBOX_LIBRARY_blobmsg_json LIBUBOX_INCLUDE_DIR) | ||
|
||
mark_as_advanced(LIBUBOX_INCLUDE_DIR LIBUBOX_LIBRARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# SYSREPO_FOUND - System has SYSREPO | ||
# SYSREPO_INCLUDE_DIRS - The SYSREPO include directories | ||
# SYSREPO_LIBRARIES - The libraries needed to use SYSREPO | ||
# SYSREPO_DEFINITIONS - Compiler switches required for using SYSREPO | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(PC_SYSREPO QUIET sysrepo) | ||
set(SYSREPO_DEFINITIONS ${PC_SYSREPO_CFLAGS_OTHER}) | ||
|
||
find_path(SYSREPO_INCLUDE_DIR sysrepo.h | ||
HINTS ${PC_SYSREPO_INCLUDEDIR} ${PC_SYSREPO_INCLUDE_DIRS} | ||
PATH_SUFFIXES sysrepo ) | ||
|
||
find_library(SYSREPO_LIBRARY NAMES sysrepo | ||
HINTS ${PC_SYSREPO_LIBDIR} ${PC_SYSREPO_LIBRARY_DIRS} ) | ||
|
||
set(SYSREPO_LIBRARIES ${SYSREPO_LIBRARY} ) | ||
set(SYSREPO_INCLUDE_DIRS ${SYSREPO_INCLUDE_DIR} ) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
# handle the QUIETLY and REQUIRED arguments and set SYSREPO_FOUND to TRUE | ||
# if all listed variables are TRUE | ||
find_package_handle_standard_args(sysrepo DEFAULT_MSG | ||
SYSREPO_LIBRARY SYSREPO_INCLUDE_DIR) | ||
|
||
mark_as_advanced(SYSREPO_INCLUDE_DIR SYSREPO_LIBRARY ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# UCI_FOUND - true if library and headers were found | ||
# UCI_INCLUDE_DIRS - include directories | ||
# UCI_LIBRARIES - library directories | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(PC_UCI QUIET uci) | ||
|
||
find_path(UCI_INCLUDE_DIR uci.h | ||
HINTS ${PC_UCI_INCLUDEDIR} ${PC_UCI_INCLUDE_DIRS}) | ||
|
||
find_library(UCI_LIBRARY NAMES uci libuci | ||
HINTS ${PC_UCI_LIBDIR} ${PC_UCI_LIBRARY_DIRS}) | ||
|
||
set(UCI_LIBRARIES ${UCI_LIBRARY}) | ||
set(UCI_INCLUDE_DIRS ${UCI_INCLUDE_DIR}) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
find_package_handle_standard_args(UCI DEFAULT_MSG UCI_LIBRARY UCI_INCLUDE_DIR) | ||
|
||
mark_as_advanced(UCI_INCLUDE_DIR UCI_LIBRARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
config ext '1000' | ||
option type 'generic' | ||
option context 'mspd1' | ||
option target 'MSPD/phone0' | ||
|
||
config general | ||
option disabled '0' | ||
option ami '1' | ||
option amihost '127.0.0.1' | ||
option amiport '5038' | ||
option amiuser 'admin' | ||
option amipass '***' | ||
|
||
config trunk 'terastream' | ||
option type 'terastream' | ||
option server 'ims.t-com.hr' | ||
option username '38521408732' | ||
option nr '+38521408732' | ||
option password '***' | ||
option codecs 'g729,g722,alaw' | ||
|
||
config ext '38521408732' | ||
option type 'external' | ||
option international '1' | ||
option trunk 'terastream' | ||
list ring '1000' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#include <sys/wait.h> | ||
#include <unistd.h> | ||
#include <sys/types.h> | ||
|
||
#include "sysrepo.h" | ||
|
||
int rpc_start(const char *xpath, const sr_val_t *input, const size_t input_cnt, | ||
sr_val_t **output, size_t *output_cnt, void *private_ctx) | ||
{ | ||
pid_t pid = fork(); | ||
if (pid == 0) { | ||
execl("/etc/init.d/asterisk", "asterisk", "start", (char *) NULL); | ||
return SR_ERR_OPERATION_FAILED; | ||
} else { | ||
waitpid(pid, 0, 0); | ||
} | ||
|
||
return SR_ERR_OK; | ||
} | ||
|
||
int rpc_stop(const char *xpath, const sr_val_t *input, const size_t input_cnt, | ||
sr_val_t **output, size_t *output_cnt, void *private_ctx) | ||
{ | ||
pid_t pid = fork(); | ||
if (pid == 0) { | ||
execl("/etc/init.d/asterisk", "asterisk", "stop", (char *) NULL); | ||
return SR_ERR_OPERATION_FAILED; | ||
} else { | ||
waitpid(pid, 0, 0); | ||
} | ||
|
||
return SR_ERR_OK; | ||
} | ||
|
||
int rpc_restart(const char *xpath, const sr_val_t *input, const size_t input_cnt, | ||
sr_val_t **output, size_t *output_cnt, void *private_ctx) | ||
{ | ||
pid_t pid = fork(); | ||
if (pid == 0) { | ||
execl("/etc/init.d/asterisk", "asterisk", "restart", (char *) NULL); | ||
return SR_ERR_OPERATION_FAILED; | ||
} else { | ||
waitpid(pid, 0, 0); | ||
} | ||
|
||
return SR_ERR_OK; | ||
} | ||
|
||
int rpc_reload(const char *xpath, const sr_val_t *input, const size_t input_cnt, | ||
sr_val_t **output, size_t *output_cnt, void *private_ctx) | ||
{ | ||
pid_t pid = fork(); | ||
if (pid == 0) { | ||
execl("/etc/init.d/asterisk", "asterisk", "reload", (char *) NULL); | ||
return SR_ERR_OPERATION_FAILED; | ||
} else { | ||
waitpid(pid, 0, 0); | ||
} | ||
|
||
return SR_ERR_OK; | ||
} | ||
|
||
int rpc_disable(const char *xpath, const sr_val_t *input, const size_t input_cnt, | ||
sr_val_t **output, size_t *output_cnt, void *private_ctx) | ||
{ | ||
pid_t pid = fork(); | ||
if (pid == 0) { | ||
execl("/etc/init.d/asterisk", "asterisk", "disable", (char *) NULL); | ||
return SR_ERR_OPERATION_FAILED; | ||
} else { | ||
waitpid(pid, 0, 0); | ||
} | ||
|
||
return SR_ERR_OK; | ||
} | ||
|
||
int rpc_enable(const char *xpath, const sr_val_t *input, const size_t input_cnt, | ||
sr_val_t **output, size_t *output_cnt, void *private_ctx) | ||
{ | ||
pid_t pid = fork(); | ||
if (pid == 0) { | ||
execl("/etc/init.d/asterisk", "asterisk", "enable", (char *) NULL); | ||
return SR_ERR_OPERATION_FAILED; | ||
} else { | ||
waitpid(pid, 0, 0); | ||
} | ||
|
||
return SR_ERR_OK; | ||
} | ||
|
||
/** | ||
* @brief RPC method consists of method identifier and signature. | ||
* | ||
* Method is meant to be used as a Sysrepo RPC callback. | ||
*/ | ||
struct rpc_method { | ||
char *name; | ||
int (*method)(const char *xpath, const sr_val_t *input, const size_t input_cnt, | ||
sr_val_t **output, size_t *output_cnt, void *private_ctx); | ||
}; |
Oops, something went wrong.