Module: kamailio Branch: master Commit: 11f207306a1da400f4252a1fafd456cda015fb3b URL: https://github.com/kamailio/kamailio/commit/11f207306a1da400f4252a1fafd456cd...
Author: Moheb bazrafshan.m.h@gmail.com Committer: Henning Westerholt hw@gilawa.com Date: 2024-09-16T13:35:01+02:00
cdp: export all functions in KEMI module
- Added `cdp_has_app` function: - Accepts a single parameter: - `application`: The Application ID.
- Added `cdp_has_app2` function: - Accepts two parameters: - `vendorid`: The Vendor ID associated with the application. - `application`: The Application ID.
- Added cdp_check_peer function: - Accepts one parameter: - `fqdn`: the Fully qualified domain name of the peer, that should be checked. The parameter may contain pseudovariables.
NOTE: All parameters are passed as standard strings.
---
Modified: src/modules/cdp/cdp_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/11f207306a1da400f4252a1fafd456cd... Patch: https://github.com/kamailio/kamailio/commit/11f207306a1da400f4252a1fafd456cd...
---
diff --git a/src/modules/cdp/cdp_mod.c b/src/modules/cdp/cdp_mod.c index 4685d2af511..b32e4ea7bf4 100644 --- a/src/modules/cdp/cdp_mod.c +++ b/src/modules/cdp/cdp_mod.c @@ -57,6 +57,7 @@ #include "cdp_functions.h" #include "cdp_tls.h" #include "../../core/mod_fix.h" +#include "../../core/kemi.h"
MODULE_VERSION
@@ -301,7 +302,10 @@ int w_cdp_check_peer(sip_msg_t *msg, char *peer, char *p2) } return -1; } - +int ki_cdp_check_peer(sip_msg_t *msg, str *peer) +{ + return w_cdp_check_peer(msg, peer->s, "NULL"); +} static int w_cdp_has_app(sip_msg_t *msg, char *appid, char *param) { unsigned int app_flags; @@ -324,6 +328,10 @@ static int w_cdp_has_app(sip_msg_t *msg, char *appid, char *param) return check_application(-1, a); }
+static int ki_cdp_has_app(sip_msg_t *msg, str *appid) +{ + return w_cdp_has_app(msg, appid->s, "NULL"); +} static int w_cdp_has_app2(sip_msg_t *msg, char *vendor, char *appid) { unsigned int vendor_flags, app_flags; @@ -359,3 +367,42 @@ static int w_cdp_has_app2(sip_msg_t *msg, char *vendor, char *appid) } return check_application(v, a); } +static int ki_cdp_has_app2(sip_msg_t *msg, str *vendor, str *appid) +{ + return w_cdp_has_app2(msg, vendor->s, appid->s); +} + +/** + * + */ +/* clang-format off */ +static sr_kemi_t sr_kemi_cdp_exports[] = { + { str_init("cdp"), str_init("cdp_check_peer"), + SR_KEMIP_INT, ki_cdp_check_peer, + { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, + { str_init("cdp"), str_init("cdp_has_app"), + SR_KEMIP_INT, ki_cdp_has_app, + { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, + { str_init("cdp"), str_init("cdp_has_app2"), + SR_KEMIP_INT, ki_cdp_has_app2, + { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + }, + + { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } } +}; +/* clang-format on */ + +/** + * + */ + +int mod_register(char *path, int *dlflags, void *p1, void *p2) +{ + sr_kemi_modules_add(sr_kemi_cdp_exports); + return 0; +}